API Reference
Integrate ComposeIt document generation into your workflows.
Generate PDF, HTML, and image files programmatically by sending JSON data payloads to your activated templates using the ComposeIt REST API.
Authentication
All API requests must include your API key in the custom header:
| Header Name | Description |
|---|---|
x-api-key | Your private organization API key. Manage these in Dashboard > API Keys. |
[!CAUTION] Treat your API keys as passwords. Do not expose them in client-side code (e.g. browsers, mobile applications) or public source control repositories.
Render Document
Generate compiled documents by compiling a template definition with dynamic data.
- Endpoint:
POST /api/export - Content-Type:
application/json
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
templateId | String | Yes | The UUID of the template you wish to render. |
templateVersion | Number | No | A specific version number to render. Defaults to the active template version. |
formats | Array | Yes | Output formats to compile. Allowed values: ["pdf", "html", "image", "mjml"]. |
data | Object | No | Key-value pairs containing variables referenced inside your template. |
expiresAt | String | No | ISO 8601 timestamp indicating when the generated download links should expire. (Default: 24 hours). |
imageType | String | No | Output format of compiled images: "png" or "jpg". (Default: "png"). |
isTest | Boolean | No | If true, compiles the document with a watermark and avoids counting against subscription usage limits. |
Request Example
curl -X POST https://app.composeit.app/api/export \
-H "Content-Type: application/json" \
-H "x-api-key: your_live_api_key_here" \
-d '{
"templateId": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"formats": ["pdf", "html"],
"isTest": false,
"data": {
"number": "INV-10024",
"date": "2026-06-26",
"due_data": "2026-07-26",
"bill_to": {
"name": "Acme Corporation",
"address": "123 Industrial Parkway, Suite A"
},
"products": [
{
"name": "Premium Plan Subscription",
"quantity": 1,
"unit_price": 99.00,
"total": 99.00
},
{
"name": "Setup & Configuration Service",
"quantity": 2,
"unit_price": 50.00,
"total": 100.00
}
],
"sub_total": 199.00,
"tax": 19.90,
"grand_total": 218.90,
"notes": "Thank you for partnering with ComposeIt!"
}
}'Response Format
Returns a JSON object mapping each requested format to its compilation result:
{
"pdf": {
"url": "https://storage.composeit.website/outputs/9b1deb4d-pdf-output.pdf",
"sizeBytes": 204550,
"mimeType": "application/pdf",
"checksum": "d3b07384d113edec49eaa6238ad5ff00"
},
"html": {
"htmlDocument": "<!DOCTYPE html><html><head><style>...</style></head><body>...</body></html>",
"checksum": "3b07384d113edec49eaa6238ad5ff001",
"mimeType": "text/html",
"url": "",
"sizeBytes": 14205
}
}Error Handling
API responses return appropriate HTTP status codes along with an error message:
400 Bad Request: Missing headers, invalid JSON payload, or unsupported format configuration.401 Unauthorized: Invalid or missingx-api-key.404 Not Found: The requested template ID does not exist.500 Internal Server Error: An unexpected server-side rendering error occurred.
Example Error Payload
{
"error": "Not found"
}