Code examples
Replace ck_YOUR_API_KEY with your organization API key and update templateId / variables for your template.
Render template to HTML (synchronous)
Resolves an **approved** template version and returns rendered HTML as a streamed response. - `templateId` is required. - The latest approved version is always used. - `variables` supplies values for `{{placeholder}}` syntax in the template. - Required sample-data fields (configured in the admin Sample Data editor) are validated against `variables` before rendering. Missing values return **400** with `code: validation_failed` and `details.missingFields` (dot paths such as `firstName` or `policies.0.endDate`).
POST /api/v1/render/html
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/html' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Monthly Report",
"user": {
"name": "Jane Doe"
}
}
}' \
--output document.htmlRender template to PDF (synchronous)
Resolves an **approved** template version, renders HTML with `variables`, converts to PDF, and returns the PDF as a streamed response. Same auth rules as `POST /api/v1/render/html`. Required sample-data fields are validated against `variables` before rendering; missing values return **400** with `code: validation_failed` and `details.missingFields`.
POST /api/v1/render/pdf
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/pdf' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Invoice",
"amount": "99.00"
}
}' \
--output document.pdfSubmit async HTML render batch
Accepts up to the platform-configured number of rows (default 500) for one HTML batch job. Returns `processBatchId` (multi-batch process id) and `batchId` (single render job id) in the **202** body. Omit `processBatchId` to start a new process with a server-generated id, or set a stable client UUID to create the process on first use or append when the process is still open. Rendering runs asynchronously. **Process completion:** If `expectedDocumentCount` is set (planned mode), the process stays open until that many rows are accepted and rendered, then the callback fires. If omitted (open-ended mode), after all in-flight jobs finish the platform waits a configurable idle grace (default 15 minutes, reset on each accepted chunk) before closing and calling `callbackUrl`.
POST /api/v1/render/batches/html
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/html' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Monthly Report",
"user": {
"name": "Jane Doe"
}
}
}' \
--output document.htmlSubmit async PDF render batch
Same as `POST /api/v1/render/batches/html` but produces PDF outputs per row. `processBatchId`, `expectedDocumentCount`, and completion semantics match the HTML batch endpoint.
POST /api/v1/render/batches/pdf
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/pdf' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Invoice",
"amount": "99.00"
}
}' \
--output document.pdfList HTML outputs for a process
Paginated HTML output metadata for a processBatchId.
GET /api/v1/render/processes/{processBatchId}/outputs/html
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/html' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Monthly Report",
"user": {
"name": "Jane Doe"
}
}
}' \
--output document.htmlList PDF outputs for a process
Paginated PDF output metadata for a processBatchId.
GET /api/v1/render/processes/{processBatchId}/outputs/pdf
curl -sS -X POST 'https://api.commspliant.com/api/v1/render/pdf' \
-H 'X-Api-Key: ck_YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"title": "Invoice",
"amount": "99.00"
}
}' \
--output document.pdf