API
Docamint provides a simple REST API for uploading templates, validating them, and generating documents.
Base URL
API Base URL
All API requests use the following base URL:
https://api.docamint.com/v1
Auth
Authentication
API requests require an API key passed in the header:
Authorization: Bearer YOUR_API_KEY
Templates
Upload Template
Upload a DOCX template to Docamint.
POST /templates/upload
Content-Type: multipart/form-data
file: invoice.docx
Response:
{
"templateId": "tmpl_12345",
"name": "invoice.docx",
"status": "uploaded"
}
Templates
Validate Template
Validate tag syntax, loops, and structure.
POST /templates/validate
{
"templateId": "tmpl_12345"
}
Response:
{
"valid": true,
"warnings": [],
"errors": []
}
Documents
Generate Document
Merge a template with JSON or XML data to produce DOCX or PDF.
POST /documents/generate
{
"templateId": "tmpl_12345",
"format": "pdf",
"payload": {
"customer": { "name": "Acme Corporation" },
"order": {
"number": "INV-2026-001",
"total": 1349.50
}
}
}
Response:
{
"documentId": "doc_98765",
"url": "https://api.docamint.com/v1/documents/doc_98765/download"
}
Documents
Download Document
Download the generated DOCX or PDF.
GET /documents/{documentId}/download
Errors
Error Responses
Common API errors:
400 - Invalid payload
404 - Template not found
422 - Template validation failed
500 - Internal server error