Documents API
The Documents API enables asynchronous document generation from source materials using MRT (Machine Readable Template) templates. Document generation is processed as a background task and returns immediately with a task ID for status tracking.Generate Document
Request document generation from source documents using an MRT template. The request is queued as a background Celery task and returns 202 Accepted.Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_type | string | Yes | Type of document (e.g., ‘CSR’, ‘Protocol’, ‘IND’) |
file_paths | array | Yes | S3 file paths for source documents |
document_set_key | string | Yes | Unique key for document set |
document_set_name | string | Yes | Human-readable name for document set |
generic_mrt_id | string | Yes | MRT template ID to use |
output_name | string | Yes | Name for generated output file |
selected_section_ids | array | No | Specific sections to include |
generic_mrt_outline_full | object | No | Full outline structure |
document_instructions | string | No | Document-level instructions |
style_guide_id | string | No | Style guide ID for formatting |
Request Example
Python Example
Response (202 Accepted)
Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Status message |
task_id | string | Celery task ID for status tracking |
Status Codes
- 202 Accepted: Request accepted for background processing
- 400 Bad Request: Missing required parameters
- 401 Unauthorized: Missing or invalid Bearer token
- 500 Internal Server Error: Database operation failed
Document Generation Pipeline
The background task performs the following steps:- Extract - Extract and classify content from source documents
- Ingest - Ingest documents using classification
- Create Outline - Generate MRT outline from template
- Orchestrate - Execute document outline rule orchestration
- Generate - Produce final DOCX document
Asynchronous Processing
The endpoint returns immediately with a task ID. Use the Status endpoint to track progress:Get Document Status
Poll the status of a document being generated.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID or task ID |
Request Example
Response
Status Values
| Status | Description |
|---|---|
Generating | Currently processing |
Complete | Successfully finished |
Failed | Encountered error |
Response Fields
| Field | Type | Description |
|---|---|---|
task_id | string | Document ID |
status | string | Current status |
progress | integer | Progress percentage (reserved for future use) |
error | string | Error message if status is Failed |
Status Codes
- 200 OK: Status retrieved successfully
- 404 Not Found: Document not found
- 500 Internal Server Error: Database error
Status Polling Workflow
Get Single Document
Retrieve a completed document by ID.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | UUID of document |
Request Example
Response
Status Codes
- 200 OK: Document retrieved successfully
- 401 Unauthorized: Missing or invalid Bearer token
- 403 Forbidden: User not authorized (different organization)
- 404 Not Found: Document not found
- 500 Internal Server Error: Database error