Authorization
AuthorizationRequiredBearer <token>API key from Settings page. Keys start with p4_live_ prefix.
In: header
Request Body
application/jsonRequiredtemplate_idstringTemplate ID (tmpl_xxx) or slug. The template must belong to the authenticated user. null reads as omitted.
htmlstringRaw HTML string. Supports Handlebars {{variables}} syntax. Use this for one-off renders without saving a template. null reads as omitted.
dataobjectData to replace {{variables}} in the template. A JSON object: null, "", false and 0 read as omitted, anything else answers 400 invalid_data. Supports strings, numbers, booleans, nested objects, and arrays (for {{#each}} blocks).
formatobjectPage format for this render. It replaces the template's format as a whole: missing fields take the defaults (A4 portrait, 20mm top/bottom and 15mm left/right margins), they are not read from the template. It prints as renders always have: an unknown preset prints a4, an unknown alignment or footer position is ignored, and a margins object prints a side it leaves out at 0 (the default margins apply only when margins is left out). null, "", false and 0 read as omitted. Only a margin (or a custom width or height) that cannot be read answers 400 invalid_format.
deliverystringHow to return the PDF. Omit for a binary application/pdf body (the default). base64 returns JSON with the bytes inline. url stores the render and returns a signed URL valid for 24 hours, which is the recommended path for PDFs over 1 MB and for AI agents that cannot hold binary in context. An organization keeps at most 200 stored renders (500 MiB) by default; past that its oldest are deleted first, so a URL can stop working sooner. After expiry the URL answers 404 render_expired.
"base64" | "url"PDF generated successfully. The body depends on delivery: a binary PDF when it is omitted, JSON when it is base64 or url.
API reference
Full reference for all PDF4.dev REST API endpoints.
Create a template
Create a new template. The `name` is required and a URL-safe `slug` is generated from it, unique in the organization. Header and footer components can be set with `header_component_id` / `footer_component_id` or with `<pdf4-header>` / `<pdf4-footer>` tags in `html`: a tag alone sets the matching id. Requires `full_access` API key scope. Errors: 400 `invalid_json`, `missing_parameter` (no `name`), `invalid_parameter`, `invalid_pdf_format`, `invalid_sample_data`, `component_not_found`, `component_type_mismatch`.