Render deterministic preview
POST/office/templates/{id}/preview
Renders a deterministic preview of the template using a provided sample data payload. The preview is generated synchronously (not queued) and returns the rendered output directly. Use in the template editor to give real-time visual feedback before publishing.
Request
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | The numeric ID of the template to preview. |
Request body
Content type application/json (required).
| Field | Type | Required | Description |
|---|---|---|---|
sample_data | object | Yes | Key-value object where keys are merge-field names and values are sample data to render. |
output_format | string | No | Format to render the preview in. One of: |
Example
{
"sample_data": {
"invoice_number": "INV-2026-0042",
"client_name": "Acme Corp",
"issue_date": "2026-04-08",
"due_date": "2026-04-22",
"line_items": [
{
"description": "Enterprise CRM licence",
"quantity": 5,
"unit_price": 800.0
}
],
"total": 4000.0
},
"output_format": "pdf"
}
Responses
200 Preview rendered successfully
Content type application/pdf, string (binary).
Content type application/json, object.
| Field | Type | Required | Description |
|---|---|---|---|
preview_url | string | No | Temporary signed URL to the preview document (expires in 15 minutes). |
Example
{
"preview_url": "https://cdn.faciotech.net/office/previews/tmp_01HXR9K2V8?token=abc123&expires=1712573400"
}
422 Validation failed — check sample_data keys match template merge fields
Example request
curl -X POST "https://{tenant}.faciotech.net/api/v1/office/templates/{id}/preview" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"sample_data": {"invoice_number": "INV-2026-0042", "client_name": "Acme Corp", "issue_date": "2026-04-08", "due_date": "2026-04-22", "line_items": [{"description": "Enterprise CRM licence", "quantity": 5, "unit_price": 800.0}], "total": 4000.0}, "output_format": "pdf"}'