Documents
Sending document HTML
Send your document HTML indocument_html. The AI reads it, makes changes, and returns updated HTML in document_changes.updated_html.
The one rule: Render the returned HTML as-is in your editor. When sending it back on the next request, send the full document HTML exactly as your editor has it. Don’t programmatically strip, modify, or reformat the HTML. If your editor or HTML sanitizer removes custom data-* attributes, configure it to preserve them.
Example flow
data-chunk-id attributes on elements. These identify document sections and enable the AI to make targeted edits without reprocessing the entire document. These same IDs appear in API responses — for example, chunk_id and insert_after_chunk_id in HITL proposed changes.
Loading documents from files
Upload a file to load it as the active document in a session. The file is processed synchronously — the response includes the full document HTML ready for editing. Supported formats: DOCX, PDF, TXT, HTML, MD (Markdown), RTFCreating documents from scratch
Send a message to an empty session (nodocument_html, no uploaded file) and the AI will generate a complete document for you.
- “Create a consulting agreement”
- “Draft a project proposal for a mobile app”
- “Write a company privacy policy”
- “Create a meeting minutes template”
Exporting documents
Export the current document as a downloadable Word file. Two modes:- Mode A — send HTML content directly (use when you have the document HTML in your app)
- Mode B — send a session ID (the API retrieves the document from the session)
doc(default) — Word-compatible file with high formatting fidelitydocx— native OOXML format, better for programmatic processing
Mode A: Export from HTML
Mode B: Export from session
Export in Python
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
html | string | One of html or session_id required | HTML content to convert |
session_id | string | One of html or session_id required | Session to export from |
format | string | No | "doc" (default) or "docx" |
filename | string | No | Custom filename (without extension). Auto-detected from the first heading if not provided. |
Supported formatting
The AI can apply the following formatting when creating or editing documents:- Text styling — bold, italic, underline, strikethrough
- Headings — H1 through H6
- Lists — ordered, unordered, and nested
- Text highlighting — with color options (e.g., yellow, green, red)
- Text color — change the color of specific text
- Links — clickable hyperlinks
- Tables — with rows and columns
- Blockquotes — indented quotation blocks
- Code blocks — for code snippets
- Horizontal rules — section dividers

