Available Endpoints:
Method |
Endpoint |
Description |
GET |
/api/templates |
List all templates |
GET |
/api/template/{id} |
Get template details |
POST |
/api/template/{id}/process |
Process template with JSON payload |
POST |
/api/process-url |
Process document from URL (headless) |
POST |
/api/extract-placeholders |
Extract placeholders from document URL |
Authentication Required
All API endpoints require Bearer token authentication. Include the header:
Authorization: Bearer YOUR_API_TOKEN
Extract Placeholders Example:
Discover what placeholders exist in a document before processing:
Request:
POST /api/extract-placeholders
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"document_url": "https://example.com/template.docx"
}
Success Response:
{
"success": true,
"placeholders": ["name", "date", "company", "address"],
"document_url": "https://example.com/template.docx"
}
Headless Processing Example:
Process documents from URLs without storing templates:
Request:
POST /api/process-url
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"document_url": "https://example.com/template.docx",
"replacements": {
"name": "John Doe",
"date": "2024-01-15",
"company": "Acme Corp"
}
}
Success Response:
{
"success": true,
"message": "Document processed successfully",
"missing_placeholders": ["{{email}}"],
"download_url": "/download/api_processed_uuid_filename.docx"
}
Markdown Support:
Replacement values support basic markdown formatting:
{
"replacements": {
"title": "# Main Heading",
"subtitle": "## Subheading",
"content": "This text has **bold formatting** and *italic text*.",
"description": "### Features\n\n* **Easy** to use\n* **Fast** processing\n* **Reliable** output"
}
}
Supported markdown: # ## ### for headings, **bold** for bold text, *italic* for italic text.
Note: Both endpoints return a download URL instead of the file directly.
Use the download_url
to fetch the processed DOCX document.
The missing_placeholders
array lists any placeholders found in the template
that weren't provided in your replacements.
Template Processing Example:
POST /api/template/{id}/process
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
{
"replacements": {
"name": "John Doe",
"company": "Acme Corp",
"date": "2024-01-15"
}
}
Success Response:
{
"success": true,
"message": "Document processed successfully",
"missing_placeholders": ["{{email}}"],
"download_url": "/download/api_processed_uuid_filename.docx"
}
Error Response:
{
"success": false,
"error": "Error message here"
}