API REFERENCE
POST /v1/render
The one endpoint. Send HTML (or a template plus data) as JSON and get application/pdf back.
Request
POST https://api.pdfinvoiceapi.com/v1/render with aBearer API key and a JSON body. Provide either html or a template (with optional data). The body is application/json; each success costs one credit.
{
"template": "<h1>Invoice {{number}}</h1><p>Bill to: {{billTo.name}}</p><p>Total: {{total}}</p>",
"data": {
"number": "INV-1024",
"billTo": { "name": "Globex LLC" },
"total": "€1,240.00"
},
"pdf": { "format": "A4", "printBackground": true }
}Body parameters
| Field | Type | Description |
|---|---|---|
| html | string | Raw HTML to render. Provide this OR template. |
| template | string | Either an inline HTML string with {{placeholders}}, OR a stored template id (tpl_…) you own. Inline: {{x}} is HTML-escaped, {{{x}}} is raw; dotted paths like {{user.name}} work. Stored: save once in the dashboard, render by id. |
| data | object | Values merged into the template (inline or stored). Ignored if html is sent. |
| object | Print options: format ("A4", "Letter"…), landscape, printBackground, margin, scale, etc. Defaults to A4 with backgrounds on. |
See the PDF options reference for every field in the pdf object.
Response
On success: 200 with the rawapplication/pdf bytes as the body — stream them to a file, a browser, or storage. Notable response headers:
| Header | Value |
|---|---|
| content-type | application/pdf |
| content-disposition | inline; filename="render.pdf" |
| x-pdf-engine | cloudflare-browser-rendering |
| x-pdf-branding | on (Trial) · off (paid) |
On failure you get a JSON error body instead of a PDF — seeErrors for every code, andRate limits & credits for throttling.