Rendering & preview
All render endpoints take the same JSON body and return a file:
{ "data": { "…": "…" }, "filename": "invoice.pdf" }
data— the Handlebars context. Omit it to fall back to the report'ssampleData.filename— optional download name; defaults to<slug>.<ext>.
| Method | Path | Returns |
|---|---|---|
POST | /api/reports/{id}/render-pdf | application/pdf (any active template kind). |
POST | /api/reports/{id}/render-docx | .docx — requires a DOCX active template. |
POST | /api/reports/{id}/render-xlsx | .xlsx — requires an XLSX active template. |
The file is returned with Content-Disposition: attachment. A wrong-kind
request (e.g. render-docx on an HTML template) returns 400 kind_mismatch. If
the report has no active template selected, the render endpoints return
422 template_missing. See Output formats.
Preview (Studio)
Both preview endpoints return text/html — never a PDF or binary. They
power the Studio's preview and take the same { data, filename } body as
the render endpoints.
| Method | Path | Returns |
|---|---|---|
POST | /api/reports/{id}/preview | text/html for any kind: the compiled HTML for HTML templates, or a LibreOffice HTML approximation for DOCX/XLSX. |
POST | /api/reports/{id}/preview-html | text/html — requires an HTML active template (else 422 html_preview_unavailable). |
The DOCX/XLSX preview is approximate, not the print-accurate PDF; use
render-pdf for the real output. Responses carry X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, and a frame-ancestors 'self' CSP.