MilaMila.gg

Get Started

Core

REST API

Agents

Pricing

Back to Mila
REST API

Documents

Documents store rich text content as HTML.


List Documents

Endpoint
GET /v1/documents

Query parameters:

ParamDefaultDescription
limit50Results per page (max 100)
offset0Pagination offset
sortupdated_atSort field: created_at, updated_at, last_edited_at, title
orderdescSort order: asc or desc
server_id(all)Filter by server: omit for all, personal for personal files, or a server ID

Example:

bash
curl https://api.mila.gg/v1/documents \
  -H "Authorization: Bearer mila_sk_your_key_here"

Get Document

Endpoint
GET /v1/documents/:id
bash
curl https://api.mila.gg/v1/documents/aB3kQ9xZwm \
  -H "Authorization: Bearer mila_sk_your_key_here"

Create Document

Endpoint
POST /v1/documents

Body:

JSON
{
  "title": "My Document",
  "content": "<h1>Hello World</h1><p>This is my document.</p>",
  "server_id": null
}
FieldTypeRequiredDescription
titlestringYesDocument title
contentstringNoHTML content
server_idstring or nullNoServer 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:

bash
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:

HTML
<!-- 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

Endpoint
PUT /v1/documents/:id

Body (all fields optional):

JSON
{
  "title": "Updated Title",
  "content": "<h1>Updated content</h1><p>New paragraph.</p>"
}
bash
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

Endpoint
POST /v1/documents/:id/append

Appends 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:

JSON
{
  "content": "<h2>New Section</h2><p>This is appended to the end.</p>"
}
FieldTypeRequiredDescription
contentstringYesHTML content to append

Note: <script> tags are automatically stripped from the appended content.

Example -- append a new section to a document:

bash
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

Endpoint
DELETE /v1/documents/:id
bash
curl -X DELETE https://api.mila.gg/v1/documents/aB3kQ9xZwm \
  -H "Authorization: Bearer mila_sk_your_key_here"