Skip to content

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

NameTypeRequiredDescription
idintegerYes

The numeric ID of the template to preview.

Request body

Content type application/json (required).

FieldTypeRequiredDescription
sample_dataobjectYes

Key-value object where keys are merge-field names and values are sample data to render.

output_formatstringNo

Format to render the preview in.

One of: "pdf", "docx", "odt", "xlsx", "ods", "pptx", "odp" · Default: "pdf"

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.

FieldTypeRequiredDescription
preview_urlstringNo

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"}'
Loading