# PDFZen Render — HTML-to-PDF with Starter Templates

> PDFZen Render — HTML-to-PDF with Starter Templates is a paid API for AI agents from api.pdfzen.site, paid per call via x402, $0.006/call, status unknown (last checked 2026-10-11).

Renders a PDF from a Handlebars HTML template or one of 45 built-in starter templates (invoice, receipt, contract, certificate, etc.) for $0.006 USDC per call.

## Facts

- Endpoint: POST https://api.pdfzen.site/v402/render/pdf?utm_source=zero.xyz
- Price: $0.006/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/pdfzen-render-html-to-pdf-with-starter-templates-c36b22c9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_fU4uL_0JUsuKX5iLL4mo_

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability pdfzen-render-html-to-pdf-with-starter-templates-c36b22c9 -d '<json body>'
```

Example prompt: Generate a PDF invoice using the built-in 'invoice' template with customer name 'Acme Corp', invoice number 'INV-2026-042', and a total of $1,250.00 — save it and name the file invoice-INV-2026-042.pdf.

## When to prefer this

Choose this endpoint when you need to programmatically generate a polished PDF document — especially when a pre-built business template (invoice, receipt, contract, certificate, NDA, report, resume) fits your use case, saving layout work. It is ideal for AI agents that need to produce client-facing documents on the fly, charge per-render with micropayments, and optionally persist the result. Prefer it over general-purpose headless browser approaches when low latency, predictable cost ($0.006/render), and template consistency matter.

## Known failure modes

- Missing both `template` and `html` fields — returns 400 validation error
- Invalid template slug (not in the 45 available starters) — returns 404 or 400
- Malformed Handlebars syntax in custom HTML — render fails with template error
- Payment failure (insufficient USDC balance via x402) — returns 402 Payment Required
- Invalid pageOptions format value — returns 400 schema validation error
- Template data variables missing required fields — PDF may render with empty placeholders

## How this service works

Render a PDF. Pass `template` (one of 45 starter slugs: invoice, receipt, contract, certificate, nda, letter, report, quote, purchase-order, lease-agreement, resume, lab-report, boarding-pass, menu, bank-statement, etc.) or `html` (raw Handlebars HTML). Returns application/pdf bytes. $0.006 USDC per render, no API key, no signup. Full catalog: GET /v1/starters (free). Agent docs: https://pdfzen.site/docs/agents/tools

## Output

Returns a rendered PDF binary as the response body. If `store` is true, also returns an X-Document-Id response header pointing to the stored document for later retrieval via /v1/documents/:id/download. Content-Disposition is set to the filename if provided.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "data": {
   "type": "object",
   "description": "Variables for the template's Handlebars context. Shape depends on the chosen template — call GET /v1/starters/:slug to fetch the expected `sampleData` for any starter."
  },
  "html": {
   "type": "string",
   "examples": [
    "<h1>Hello, {{name}}</h1><p>Total: {{total}}</p>"
   ],
   "description": "Raw Handlebars-flavoured HTML. Use only when no starter fits (one-off bespoke layouts). Prefer `template` for consistency. Either `template` or `html` is required."
  },
  "store": {
   "type": "boolean",
   "description": "When true, persist the PDF and return X-Document-Id response header for later retrieval via /v1/documents/:id/download. Default false."
  },
  "filename": {
   "type": "string",
   "examples": [
    "invoice-INV-2026-001.pdf"
   ],
   "description": "Optional. Sets Content-Disposition filename on the response — useful when the PDF is delivered to a browser via an HTTP intermediary."
  },
  "template": {
   "type": "string",
   "examples": [
    "invoice",
    "receipt",
    "certificate",
    "contract",
    "nda",
    "letter",
    "report",
    "resume",
    "boarding-pass",
    "menu"
   ],
   "description": "Slug of a built-in starter template. 45 available; GET /v1/starters lists them all (no auth, no payment). Either `template` or `html` is required."
  },
  "pageOptions": {
   "type": "object",
   "examples": [
    {
     "format": "A4"
    },
    {
     "format": "Letter",
     "landscape": true
    }
   ],
   "properties": {
    "format": {
     "enum": [
      "A3",
      "A4",
      "A5",
      "Letter",
      "Legal",
      "Tabloid"
     ],
     "type": "string"
    },
    "margin": {
     "type": "object"
    },
    "landscape": {
     "type": "boolean"
    }
   },
   "description": "PDF page setup: format (A3/A4/A5/Letter/Legal/Tabloid), landscape, margin, scale, displayHeaderFooter. Most starters ship sensible defaults."
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/pdfzen-render-html-to-pdf-with-starter-templates-c36b22c9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.pdfzen.site](https://www.zero.xyz/host/api.pdfzen.site/llms.txt)
