Generate a PDF
POST /v1/generate
Renders one of your templates with the supplied data and returns a PDF. Requires a valid API key.
Request body
| Field | Type | Description |
|---|---|---|
template_id | string | Required. The id of a template you own. |
data | object | The values merged into the template's placeholders (max 256 KB). |
options.output | string | "binary" (default) returns the PDF bytes; "url" returns a 24-hour signed URL. |
Example
curl -X POST https://paperfox.dev/v1/generate \
-H "Authorization: Bearer pf_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{ "template_id": "tmpl_…", "data": { "total": 3078 } }' \
--output invoice.pdfResponses
Binary (default). 200 OK with Content-Type: application/pdf — the response body is the PDF.
Signed URL. With { "options": { "output": "url" } }:
{ "url": "https://…/signed.pdf", "expires_at": "2026-07-01T12:00:00.000Z" }Notes
- Typical render time is ~2 seconds. Requests time out at 20s (
504 render_timeout). - Each successful generation counts toward your monthly quota. Exceeding it returns
402 quota_exceeded. - Templates only format data — compute business values (subtotal, tax, total) on your side and pass them in. See Template syntax.
- PaperFox stores no document data: generation logs keep metadata only (status, duration, size).
Full status/code list: Errors.