Skip to main content

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.
Access rules:
  • Internal / Owner roles: all documents within their organization
  • All other roles: only documents in document sets they belong to

Request Example

Response

Response Fields

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 returned task_id to poll status.

Request Body

Fields marked with an alias can be sent using either name — both are accepted.
The following field names are interchangeable:

Python Example

Response (202 Accepted)

Response Fields

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 same output_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:
  1. Extract — Extract and classify content from source documents
  2. Ingest — Ingest documents using classification results
  3. Create Outline — Generate an outline from the template
  4. Orchestrate — Execute document outline rule orchestration
  5. Generate — Produce the final DOCX document

Get Document Status

Poll the current status of a document being generated.

Path Parameters

Request Example

Response

Status Values

Response Fields

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

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 Only .docx files are accepted.

Request Example

Python Example

Response (201 Created)

Response Fields

Status Codes

  • 201 Created: Document uploaded and record created successfully
  • 400 Bad Request: Invalid file type (only .docx accepted)
  • 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

Request Example

Python Example

Response

Response Fields

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

Complete Workflow Example