API URL
POST /api/v1/document-generation/:documentType/generate
Headers
Code
Content-Type: application/jsonBody Parameters
Param
Type
Description
documentType
required
string
Document identifier used to select a schema and output contract
templateVersion
optional
string
Supported template contract version
mode
optional
string
Render mode blank or filled
data
optional
object
Document payload validated against the document schema
requests
required
array
One to five document requests for batch generation
branding_organizationName
optional
string
Organization label for branded output
branding_logoText
optional
string
Text brand mark rendered in the document header
branding_primaryColor
optional
string
Hex color for header and table accents
branding_accentColor
optional
string
Hex color for title accents
branding_footerText
optional
string
Footer text rendered in generated documents
output_type
optional
string
Output type pdf or docx for generate and html pdf or docx for batch
output_format
optional
string
PDF output format A4 Letter Legal Tabloid
output_responseType
optional
string
PDF or DOCX response mode binary or base64
output_landscape
optional
boolean
Landscape output toggle for PDF
output_margins
optional
object
Margin object top right bottom left values
Example Request
Code
POST https://datpaq.com/api/v1/document-generation/invoice/generate?api_key=your-api-key | Body: {"mode":"filled","templateVersion":"1.0.0","data":{"invoiceNumber":"INV-2026-0042","invoiceDate":"2026-09-02","dueDate":"2026-10-02","sellerName":"Datpaq","customerName":"Example Corporation","currency":"USD","taxRate":0,"items":[{"description":"API Platform Subscription","quantity":1,"unitPrice":499}]},"output":{"type":"docx","responseType":"base64"}}Successful Response
Status
HTML
200 OKBody
Code
{
"success": true,
"docxBase64": "UEsDB...",
"documentMetadata": {
"documentType": "invoice",
"templateVersion": "1.0.0",
"mode": "filled",
"format": "DOCX",
"byteLength": 12345,
"timingMs": 120
},
"metadata": {
"correlationId": "req_abc123"
}
}Field
Type
success
boolean
documents
array
schema
object
jsonSchema
object
example
object
results
array
pdfBase64
string
docxBase64
string
documentMetadata
object
templateVersion
string
metadata
object
error
string
details
array
status
string
service
string
version
string
documentsAvailable
number
documentType
string
index
number
total
number
failed
number
outputType
string
html
string
retryAfter
number
correlationId
string
Error Response
Example
Code
HTTP 400 ValidationError: Missing fields malformed data invalid template version invalid branding or invalid output selection — Request rejected before render or generation; HTTP 401 AuthenticationError: Gateway rejects missing or invalid API key — Authentication enforcement before business processing; HTTP 404 NotFound: Unknown document type or endpoint — Requested resource not available; HTTP 429 RateLimitError: Rate limiter threshold exceeded — Too many requests in active window; HTTP 503 PoolSaturated: Chromium pool at concurrency capacity — Service is temporarily busy; HTTP 500 InternalError: Unexpected render or generation failure or malformed or oversized JSON body — Unhandled generation or shared parser failureLast Updated: May 4, 2026