Developers
DocuNext API reference
Use the DocuNext REST API to upload and list templates, then generate PDF or DOCX files from DOCX and ODT templates. The API uses resource-oriented URLs, bearer-token authentication, JSON request bodies, and standard HTTP status codes.
Base URL
API routes are served from the same deployed DocuNext application as your dashboard.
https://www.docunext.appAuthentication
Send an API key in the Authorization header using the Bearer scheme. API keys are shown only once when they are created. Store them securely and rotate keys from the dashboard if a key is exposed.
Authorization: Bearer dn_live_...Key handling
- Keep keys on your server. Do not expose them in browser code.
- Use one key per integration or environment.
- Delete and recreate a key when rotating credentials.
/api/v1/templatesList templates
Returns the authenticated account's templates, including each template's detected placeholder fields. Use this endpoint to discover the template_id and field names needed for generation.
curl https://www.docunext.app/api/v1/templates \
-H "Authorization: Bearer dn_live_..."Response
The response is JSON and is never cached.
{
"templates": [
{
"id": "7b7e4b76-8f54-4a6f-9f82-21e5c91880aa",
"name": "Invoice",
"filename": "invoice-template.docx",
"status": "ready",
"updated_at": "2026-06-24T05:38:12.083Z",
"fields": ["customer_name", "invoice_number", "invoice_total"]
}
]
}/api/v1/templatesUpload a template
Uploads one DOCX or ODT template, detects placeholders, stores the file privately, and returns the created template metadata. Send this request as multipart/form-data.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | One DOCX or ODT template file. The file must be 10 MB or smaller and contain at least one valid placeholder. |
| folder_id | uuid | No | Destination template folder. Omit this field to upload to Home. |
curl https://www.docunext.app/api/v1/templates -X POST -H "Authorization: Bearer dn_live_..." -F "file=@./invoice-template.docx" -F "folder_id=2a8c6af5-7d2d-42f8-9d6a-57c7c3b67d44"Response
The response is JSON and includes the detected placeholder fields.
{
"template": {
"id": "7b7e4b76-8f54-4a6f-9f82-21e5c91880aa",
"name": "Invoice Template",
"filename": "invoice-template.docx",
"folder_id": "2a8c6af5-7d2d-42f8-9d6a-57c7c3b67d44",
"status": "ready",
"updated_at": "2026-06-24T05:38:12.083Z",
"fields": ["customer_name", "invoice_number", "invoice_total"]
}
}/api/v1/documents/generateGenerate a document
Renders a template with supplied field values and returns the generated file as the response body. PDF is the default output format.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| template_id | uuid | Yes | The template ID returned by the templates endpoint. |
| output_format | "pdf" | "docx" | No | The generated file type. Defaults to pdf when omitted. |
| output_filename | string | No | Optional output filename without the extension. The server sanitizes it and appends the selected output format. |
| data | object | Yes | Placeholder values keyed by field name. String, number, boolean, null, and undefined values are accepted; all values are rendered as strings. |
curl https://www.docunext.app/api/v1/documents/generate \
-X POST \
-H "Authorization: Bearer dn_live_..." \
-H "Content-Type: application/json" \
-o invoice.pdf \
--data '{
"template_id": "7b7e4b76-8f54-4a6f-9f82-21e5c91880aa",
"output_format": "pdf",
"output_filename": "acme-invoice-1042",
"data": {
"customer_name": "Acme Pty Ltd",
"invoice_number": "INV-1042",
"invoice_total": "$1,240.00"
}
}'Successful response
The response body is the generated binary file. Save it using the response bytes. The filename and document ID are returned as headers.
- Content-Type
- PDF: application/pdfDOCX: Word document MIME type
- X-Document-Id
- The generated document UUID.
- X-Document-Filename
- URL-encoded output filename.
Field behavior
- Placeholder names are discovered from uploaded templates.
- Unknown fields are ignored by rendering.
- Every detected field must be present in data. Omitted fields return a missing_field error.
- Each value may be up to 10,000 characters.
Errors
Error responses use a consistent JSON envelope with a machine-readable code and a human-readable message.
{
"error": {
"code": "invalid_request",
"message": "The generation request is invalid."
}
}| Code | Status | Meaning |
|---|---|---|
| missing_authorization | 401 | The Authorization header was not sent. |
| invalid_authorization | 401 | The Authorization header is malformed. |
| invalid_api_key | 401 | The API key is invalid or could not be verified. |
| revoked_api_key | 401 | The API key was revoked. |
| invalid_json | 400 | The request body is not valid JSON. |
| invalid_request | 400 | The request shape, multipart upload, template ID, output format, or data object is invalid. |
| request_too_large | 413 | The request body exceeded the allowed size. |
| rate_limit_exceeded | 429 | Too many requests were sent with the same API key in the current window. |
| templates_unavailable | 500 | Templates could not be loaded. |
| invalid_template | 422 | The uploaded template could not be inspected or has no valid placeholders. |
| template_upload_failed | 500 | The template file, metadata, or fields could not be saved. |
| template_not_found | 404 | The template does not exist or belongs to another workspace. |
| quota_exceeded | 402 | The workspace has used its monthly page limit. |
| invalid_render_data | 422 | The render data could not be parsed. |
| missing_field | 422 | A template placeholder has no value in the request data. |
| unsupported_output_format | 422 | The template cannot be rendered in the requested output format. |
| template_render_failed | 422 | The template could not be rendered. |
| conversion_failed | 502 | The rendered document could not be converted to PDF. Retry later. |
| internal_error | 500 | An unexpected error occurred. Retry later. |
Limits
Request body
1.1 MB
Template upload
10 MB
Fields per request
100
Execution window
60 sec
List templates
120/min
Upload templates
20/min
Generate documents
30/min
Generated files are returned directly to the caller. Successful API generations are persisted asynchronously for usage tracking and document history.