Which document types are available?
GET /documents lists the registry, including invoices, receipts, quotes, and HR letters such as employment verification and offer letters. Each type has a stable schema and templateVersion 1.0.0.
Generate branded invoices, letters, and HR forms from a code-owned registry. Validate once, then render HTML, PDF, or DOCX without custom templates.
This calls the live Document Generation API. Browse the catalog, inspect the invoice example, or generate a canned DOCX. The demo waits for you to run it.
Why Document Generation API
Registry catalog
GET /documents lists types, categories, modes, and outputs so clients do not hard-code schemas.
Schema contracts
Per-type schema, JSON Schema, and example payloads keep agent and form builders in sync.
HTML previews
Blank GET render and filled POST render return printable HTML before a file is generated.
PDF and DOCX
POST generate returns Chromium PDF or Office Open XML DOCX as binary or base64.
Request branding
Logo text, primary and accent colors, and footer copy apply per request without remote assets.
Capped batch
POST /batch accepts one to five document requests and returns per-item HTML or base64 files.
/api/v1/document-generation
List document types
Registry catalog with id, name, category, modes, outputs, and templateVersion.
Example payload
Valid filled sample request for one registered document type.
Generate PDF or DOCX
Validates data against the registry and returns binary or base64 output.
Document schema
Public field contract, collections, and template version for one type.
Batch generate
One to five document requests with per-item HTML, PDF, or DOCX results.
Service health
Status, service name, version, document count, timestamp, and correlation metadata.
Prometheus metrics
Request counts and latency histograms in Prometheus exposition format.
| Parameter | Type | Required | Description |
|---|---|---|---|
| documentType | string | path | Registry id such as invoice or employment-verification. |
| mode | string | no | blank or filled. Default filled. |
| templateVersion | string | no | Supported contract version. Must be 1.0.0. |
| data | object | filled | Payload validated against the document schema. |
| output.type | string | no | pdf or docx for generate. html, pdf, or docx for batch. |
| output.responseType | string | no | binary or base64. Default binary. |
| output.format | string | no | PDF page size: A4, Letter, Legal, or Tabloid. |
| requests | array | batch | One to five document requests for POST /batch. |
Error reference
Invalid schema, missing required fields, unsupported template version, or malformed output.
Missing or invalid gateway API key. Send x-api-key or api_key with every request.
Unknown document type or unknown route under /api/v1/document-generation.
More than 20 requests in a 15-minute window per IP.
Chromium render pool is saturated. Retry after the service reports capacity.
Example error response
{
"success": false,
"error": "Invalid input parameters",
"details": ["data.invoiceNumber is required"],
"metadata": { "correlationId": "req_abc123" }
}FAQ
GET /documents lists the registry, including invoices, receipts, quotes, and HR letters such as employment verification and offer letters. Each type has a stable schema and templateVersion 1.0.0.
POST /:documentType/generate with a validated data object. Set output.type to pdf or docx. Use responseType base64 for JSON, or binary for a downloadable file.
Yes. GET /:documentType/render returns a blank HTML form. POST the same path with filled data for an HTML preview. GET /:documentType/example returns a valid sample payload.
No. v1 uses the local registry and request-scoped branding fields. Remote logo fetching and unsupported template versions are rejected.
Send your Datpaq API key as an x-api-key header or an api_key query parameter. Keys are created in the Datpaq dashboard and a free tier is included.
Validated JSON in, branded HTML, PDF, or DOCX out, from a registry of business document types.