Skip to main content

Preview a template without generating a document

POST 

/v1/docgen/templates/:id/preview

Render a saved template against supplied data and return it for review, without creating a document. No generated document is stored and no generation quota is consumed — use this to let a user inspect the merged result (and any unresolved-token warnings) before committing to POST /v1/docgen/documents.

The response shape depends on the template's source format:

  • Word (.docx) templates render to a PDF returned as a short-lived previewUrl (a presigned download URL) plus its expiresAt. Fetch the URL before it expires; call this endpoint again for a fresh one. The PDF is never returned inline, so the bytes never have to fit in a caller's memory budget.
  • HTML / Markdown templates render to sanitized html plus a csp object you can apply when displaying it in an iframe.

Both variants include diagnostics[] describing unresolved merge tokens, unknown helpers, and malformed merge expressions found while rendering.

Requires the dedicated docgen:preview scope. A token scoped only for docgen:read, docgen:write, or docgen:admin is rejected.

Request

Responses

Rendered preview. A PDF variant (Word templates) or an HTML variant (HTML/Markdown templates).

Response Headers
    X-Request-Id

    Correlation id for this request, returned on every response (success and error). Quote it when contacting support to pinpoint the exact request, and use it to correlate your own logs. It is the same 128-bit id as the trace-id segment of the traceparent header.

    traceparent

    W3C Trace Context identifier for this request, returned on every response. Send your own traceparent on a request to have it adopted, so a multi-call workflow shares one trace. Format: 00-<32-hex trace-id>-<16-hex span-id>-<2-hex flags>.