Documents API
The Documents API enables asynchronous document generation from source materials using structured templates. Document generation is processed as a background Celery task and returns immediately with a document ID for status tracking.List Documents
Retrieve all documents accessible to the authenticated user across all their document sets.- Internal / Owner roles: all documents within their organization
- All other roles: only documents in document sets they belong to
Request Example
Response
Response Fields
| Field | Type | Description |
|---|---|---|
documents | array | List of document items |
documents[].document_id | string | Document UUID |
documents[].document_name | string | Document file name |
documents[].created_at | string | Creation timestamp |
documents[].updated_at | string | Last updated timestamp |
documents[].workspace_id | string | Document set ID the document belongs to |
documents[].template | object | Template metadata (null if no template) |
documents[].template.template_id | string | Template UUID |
documents[].template.template_name | string | Template name |
Status Codes
- 200 OK: Documents retrieved successfully
- 401 Unauthorized: Missing or invalid Bearer token
- 500 Internal Server Error: Database error
Generate Document
Request document generation from source documents using a template. The request is queued as a background Celery task and returns 202 Accepted immediately. A placeholder document record is created synchronously before queuing — use the returnedtask_id to poll status.
Request Body
Fields marked with an alias can be sent using either name — both are accepted.| Alias (also accepted) | Internal field name |
|---|---|
connector_data_id | document_set_key |
template_id | generic_mrt_id |
workspace_name | document_set_name |
Python Example
Response (202 Accepted)
Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Status message |
task_id | string | The document UUID — use this to poll status and retrieve the document |
Status Codes
- 202 Accepted: Request accepted for background processing
- 400 Bad Request: Missing required parameters or document set not found
- 401 Unauthorized: Missing or invalid Bearer token
- 500 Internal Server Error: Database operation failed
Idempotency
If a document with the sameoutput_name already exists for your organization, the existing document ID is returned immediately (no duplicate is created).
Document Generation Pipeline
The background task performs the following steps:- Extract — Extract and classify content from source documents
- Ingest — Ingest documents using classification results
- Create Outline — Generate an outline from the template
- Orchestrate — Execute document outline rule orchestration
- Generate — Produce the final DOCX document
Get Document Status
Poll the current status of a document being generated.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | UUID of the document (returned as task_id from /generate) |
Request Example
Response
Status Values
| Status | Description |
|---|---|
Pending | Document accepted but not yet picked up by a worker |
Ingesting | Source documents are being ingested |
Generating | Document content is being generated |
Ready | Document generation completed successfully |
Failed | Document generation encountered an error |
Response Fields
| Field | Type | Description |
|---|---|---|
task_id | string | Document UUID |
status | string | Current processing status |
progress | integer | Progress percentage (reserved — currently always null) |
error | string | Error message if status is "Failed", otherwise null |
Status Codes
- 200 OK: Status retrieved successfully
- 404 Not Found: Document not found
- 500 Internal Server Error: Database error
Polling Workflow
Get Single Document
Retrieve a completed document by ID. Returns all document metadata and sections.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | UUID of the document |
Request Example
Response
Status Codes
- 200 OK: Document retrieved successfully
- 401 Unauthorized: Missing or invalid Bearer token
- 403 Forbidden: Document belongs to a different organization
- 404 Not Found: Document not found
- 500 Internal Server Error: Database error
Create Local Document
Upload a Word document directly from the Office Add-in and create a minimal document record. Unlike/generate, this does not process the document through the generation pipeline — it simply stores the document for use with chat functionality.
Request
Content-Type:multipart/form-data
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The .docx file to upload |
.docx files are accepted.
Request Example
Python Example
Response (201 Created)
Response Fields
| Field | Type | Description |
|---|---|---|
document_id | string | UUID of the created document |
document_name | string | Name of the uploaded file |
s3_key | string | S3 key where the document is stored |
status | string | Always "Ready" for local documents |
Status Codes
- 201 Created: Document uploaded and record created successfully
- 400 Bad Request: Invalid file type (only
.docxaccepted) - 401 Unauthorized: Authentication failed
- 500 Internal Server Error: S3 upload or database error
Get Sections for Document
Retrieve a flat list of all section identifiers and their associated metadata within a given document. Used to enumerate the full section structure, enabling the Sources panel selection dropdown to be pre-populated with all available sections upon document load.Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Unique identifier of the document whose section list is being retrieved. Must reference an existing document accessible by the authenticated user. |
Request Example
Python Example
Response
Response Fields
| Field | Type | Description |
|---|---|---|
sections | array | Array of section objects, sorted by document order |
sections[].section_id | string | Unique identifier of the section (the section title). Used as section_id in the get-sources-for-selected-text endpoint. |
sections[].section_title | string | Human-readable display name of the section, rendered as an option in the Sources panel selection dropdown. |
sections[].section_order | integer | Zero-based index representing the section’s position within the document, used to render dropdown options in document order. |
Status Codes
- 200 OK: Successfully retrieved section list
- 400 Bad Request: Authentication failed or invalid Bearer token
- 404 Not Found: Document MRT not found for the given document ID