Templates API
The Templates API manages templates with nested sections and content extraction rules. Templates define the structure and content requirements for generated documents.List Templates
Retrieve all templates accessible to the authenticated user, sorted by creation date (newest first).Request Example
Response
Status Codes
- 200 OK: Templates retrieved successfully
- 401 Unauthorized: Missing or invalid Bearer token
Get Single Template
Retrieve a specific template with full details including sections, rules, users, and style information.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template |
Request Example
Response
Status Codes
- 200 OK: Template retrieved successfully
- 400 Bad Request: Authentication failure
- 404 Not Found: Template not found
Create Template
Create a new template with nested sections and extraction rules.Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_name | string | Yes | Template name |
document_type | string | Yes | Document type (e.g., "CSR", "IND", "NDA") |
sections | array | Yes | At least one section required |
template_s3_uri | string | Required* | S3 URI for the template file |
template_file_name | string | Required* | Template file name (alternative to template_s3_uri) |
document_description | string | No | Description |
tags | array | No | Categorization tags |
users | array | No | User IDs to grant access |
template_s3_uri or template_file_name must be provided.
Section Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
order_index | integer | Yes | Position in template (0-based, must be unique) |
level | integer | Yes | Nesting level (1 = top-level, 2 = subsection, etc.) |
section_name | string | Yes | Section title |
synopsis | string | No | Brief summary |
template_instructions | string | No | Completion instructions |
template_text | string | No | Template text |
section_type | string | No | Section type classification |
section_mode | string | No | Operation mode |
is_repeating | boolean | No | Default: false |
expansion_type | string | No | For repeating sections |
rules | array | No | Extraction rules for the section |
Request Example
Python Example
Response (201 Created)
Response Fields
| Field | Type | Description |
|---|---|---|
template_id | string | UUID of the created template |
template_name | string | Name of the template |
organization_id | string | Organization UUID |
section_count | integer | Number of sections created |
rule_count | integer | Total number of rules across all sections |
created_at | string | ISO 8601 creation timestamp |
message | string | Success message |
Status Codes
- 201 Created: Template created successfully
- 400 Bad Request: Validation errors (missing fields, duplicate
order_index, missingtemplate_s3_uri/template_file_name) - 401 Unauthorized: Authentication failure
- 500 Internal Server Error: Database operation failure
Add Section to Template
Add a new section to an existing template.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template |
Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
section_name | string | Yes | Name/title of the section |
level | integer | Yes | Nesting level (1 = top-level, 2 = subsection, etc.) |
order_index | integer | Yes | Position in the template (0-based) |
Request Example
Response
Status Codes
- 200 OK: Section added successfully
- 400 Bad Request: Authentication errors
- 403 Forbidden: Unauthorized access
- 404 Not Found: Template not found
- 500 Internal Server Error: Database operation failure
Rename Template Section
Update the name of an existing template section.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template |
section_id | string | Yes | UUID of the section to rename |
Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
section_name | string | Yes | New name for the section (e.g., "2.1 Efficacy Results") |
Request Example
Response
Status Codes
- 200 OK: Section renamed successfully
- 400 Bad Request: Authentication errors
- 403 Forbidden: Unauthorized access
- 404 Not Found: Template or section not found
- 500 Internal Server Error: Database operation failure
Reorder Template Sections
Reorder and automatically renumber all sections in a template. After reordering, section names are renumbered to reflect the new hierarchy (e.g.,"1.", "1.1", "2.").
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template |
Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
sections | array | Yes | List of {section_id, order_index, level} objects defining the new order |
Request Example
Response
Status Codes
- 200 OK: Sections reordered successfully
- 400 Bad Request: Authentication errors
- 403 Forbidden: Unauthorized access
- 404 Not Found: Template not found
- 500 Internal Server Error: Database operation failure
Update Rule Styles
Update the style names, fill color, and/or text color for a specific rule within a template section.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template (used for authorization) |
rule_id | string | Yes | UUID of the rule to update |
Request Body
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
style_names | array | No | List of Word style names to apply (e.g., ["Heading 2", "Normal"]) |
fill | string | No | Background fill color as hex (e.g., "#FFFF00"), or null/"" to remove |
color | string | No | Text/font color as hex (e.g., "#FF0000"), or null/"" to remove |
Request Example
Response
Status Codes
- 200 OK: Rule styles updated successfully
- 400 Bad Request: Authentication errors
- 403 Forbidden: Unauthorized access
- 404 Not Found: Template or rule not found
- 500 Internal Server Error: Database operation failure
Delete Template Section
Delete a section from an template. Associated rules are automatically deleted via CASCADE.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
template_id | string | Yes | UUID of the template |
section_id | string | Yes | UUID of the section to delete |
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
cascade_children | boolean | No | true | If true, also delete child sections at deeper nesting levels |
Request Example
Response
Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Success message |
deleted_section_id | string | UUID of the deleted section |
deleted_count | integer | Total number of sections deleted (includes children if cascaded) |
Status Codes
- 200 OK: Section deleted successfully
- 400 Bad Request: Invalid parameters
- 403 Forbidden: Not authorized
- 404 Not Found: Template or section not found