Documents
Documents store rich text content as HTML.
List Documents
GET /v1/documentsQuery parameters:
| Param | Default | Description |
|---|---|---|
limit | 50 | Results per page (max 100) |
offset | 0 | Pagination offset |
sort | updated_at | Sort field: created_at, updated_at, last_edited_at, title |
order | desc | Sort order: asc or desc |
server_id | (all) | Filter by server: omit for all, personal for personal files, or a server ID |
Example:
curl https://api.mila.gg/v1/documents \
-H "Authorization: Bearer mila_sk_your_key_here"Get Document
GET /v1/documents/:idcurl https://api.mila.gg/v1/documents/aB3kQ9xZwm \
-H "Authorization: Bearer mila_sk_your_key_here"Create Document
POST /v1/documentsBody:
{
"title": "My Document",
"content": "<h1>Hello World</h1><p>This is my document.</p>",
"server_id": null
}| Field | Type | Required | Description |
|---|---|---|---|
title | string | Yes | Document title |
content | string | No | HTML content |
server_id | string or null | No | Server to create in (null = personal files) |
The content field accepts HTML. You can use any standard HTML elements -- headings, paragraphs, lists, tables, images, etc.
Note:
<script>tags are automatically stripped from content for security. Your request will still succeed, the scripts are just silently removed.
Example -- create a document with rich content:
curl -X POST https://api.mila.gg/v1/documents \
-H "Authorization: Bearer mila_sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"title": "Project Brief",
"content": "<h1>Project Brief</h1><p>This project aims to <strong>improve</strong> our onboarding flow.</p><h2>Goals</h2><ul><li>Reduce time-to-value</li><li>Increase activation rate</li></ul><h2>Timeline</h2><p>We plan to ship by <em>Q3 2026</em>.</p>"
}'Content format reference:
<!-- Headings -->
<h1>Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>
<!-- Text -->
<p>Regular paragraph with <strong>bold</strong> and <em>italic</em> text.</p>
<!-- Lists -->
<ul>
<li>Unordered item</li>
</ul>
<ol>
<li>Ordered item</li>
</ol>
<!-- Tables -->
<table>
<tr><th>Name</th><th>Role</th></tr>
<tr><td>Alice</td><td>Engineer</td></tr>
</table>
<!-- Images -->
<img src="https://example.com/photo.png" alt="Description" />
<!-- Links -->
<a href="https://example.com">Link text</a>Update Document
PUT /v1/documents/:idBody (all fields optional):
{
"title": "Updated Title",
"content": "<h1>Updated content</h1><p>New paragraph.</p>"
}curl -X PUT https://api.mila.gg/v1/documents/aB3kQ9xZwm \
-H "Authorization: Bearer mila_sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{"title": "Renamed Document"}'Append to Document
POST /v1/documents/:id/appendAppends HTML content to the end of an existing document. Unlike PUT, this does not replace the existing content -- it concatenates the new content after it.
Body:
{
"content": "<h2>New Section</h2><p>This is appended to the end.</p>"
}| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | HTML content to append |
Note:
<script>tags are automatically stripped from the appended content.
Example -- append a new section to a document:
curl -X POST https://api.mila.gg/v1/documents/aB3kQ9xZwm/append \
-H "Authorization: Bearer mila_sk_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"content": "<h2>Meeting Notes</h2><p>Discussed roadmap priorities for Q3.</p><ul><li>Feature A - high priority</li><li>Feature B - medium priority</li></ul>"
}'This is useful for incrementally building documents, logging entries, or adding content from automated workflows without needing to read the full document first.
Delete Document
DELETE /v1/documents/:idcurl -X DELETE https://api.mila.gg/v1/documents/aB3kQ9xZwm \
-H "Authorization: Bearer mila_sk_your_key_here"