Skip to content

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.app

Authentication

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.

Header
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.
GET/api/v1/templates

List 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.

200 OK
{
  "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"]
    }
  ]
}
POST/api/v1/templates

Upload 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

NameTypeRequiredDescription
filefileYesOne DOCX or ODT template file. The file must be 10 MB or smaller and contain at least one valid placeholder.
folder_iduuidNoDestination 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.

201 Created
{
  "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"]
  }
}
POST/api/v1/documents/generate

Generate 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

NameTypeRequiredDescription
template_iduuidYesThe template ID returned by the templates endpoint.
output_format"pdf" | "docx"NoThe generated file type. Defaults to pdf when omitted.
output_filenamestringNoOptional output filename without the extension. The server sanitizes it and appends the selected output format.
dataobjectYesPlaceholder 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 response
{
  "error": {
    "code": "invalid_request",
    "message": "The generation request is invalid."
  }
}
CodeStatusMeaning
missing_authorization401The Authorization header was not sent.
invalid_authorization401The Authorization header is malformed.
invalid_api_key401The API key is invalid or could not be verified.
revoked_api_key401The API key was revoked.
invalid_json400The request body is not valid JSON.
invalid_request400The request shape, multipart upload, template ID, output format, or data object is invalid.
request_too_large413The request body exceeded the allowed size.
rate_limit_exceeded429Too many requests were sent with the same API key in the current window.
templates_unavailable500Templates could not be loaded.
invalid_template422The uploaded template could not be inspected or has no valid placeholders.
template_upload_failed500The template file, metadata, or fields could not be saved.
template_not_found404The template does not exist or belongs to another workspace.
quota_exceeded402The workspace has used its monthly page limit.
invalid_render_data422The render data could not be parsed.
missing_field422A template placeholder has no value in the request data.
unsupported_output_format422The template cannot be rendered in the requested output format.
template_render_failed422The template could not be rendered.
conversion_failed502The rendered document could not be converted to PDF. Retry later.
internal_error500An 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.