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-livedpreviewUrl(a presigned download URL) plus itsexpiresAt. 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
htmlplus acspobject 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
- 200
- 403
- 404
Rendered preview. A PDF variant (Word templates) or an HTML variant (HTML/Markdown templates).
Response Headers
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.
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>.
The token does not carry the docgen:preview scope.
Response Headers
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.
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>.
Template not found.
Response Headers
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.
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>.