# pdfzen > HTML to PDF API. Pay-as-you-go renders, 45 starter templates, and a dedicated x402 surface so AI agents can render PDFs without ever signing up for an account. pdfzen renders HTML + Handlebars templates into PDFs over a REST API. Two billing tracks: - **Credit-based** for human accounts (`/v1/render/pdf` with a Bearer API key, $0.005/render at base tier with auto-applied volume discounts). - **Per-request x402** for AI agents (`/v402/render/pdf` with a USDC payment header on Base, $0.006/render, no signup or API key). Identity for x402 callers is the wallet address that signs each request. Saving, listing, and deleting custom HTML templates is **free** for x402 wallets — only renders are paid. Caps: 100 templates per wallet, 256 KB per template body. ## Common agent tasks Match the user's intent against these recipes; each names the right endpoint and the minimum input. All x402 endpoints settle in USDC on Base via the `X-PAYMENT` header — most agent SDKs (`x402-fetch`, Coinbase Agent Kit) handle the 402 challenge round-trip automatically. - **Render a PDF from a built-in template** ("make me an invoice", "create a certificate of completion"): POST to `https://api.pdfzen.site/v402/render/pdf` with `{ "template": "", "data": { … } }`. Slugs include `invoice`, `receipt`, `certificate`, `contract`, `nda`, `letter`, `report`, `quote`, `purchase-order`, `lease-agreement`, `resume`, `cover-letter`, `lab-report`, `recipe-card`, `boarding-pass`, `business-card`, `brochure-trifold`, `menu`, `conference-badge`, `gift-certificate`, `bank-statement`, plus 24 more — see `/v1/starters` for the full list. - **Render a PDF from agent-provided HTML** ("turn this HTML into a PDF"): POST to `https://api.pdfzen.site/v402/render/pdf` with `{ "html": "", "pageOptions": { "format": "A4" } }`. Handlebars expressions in the HTML are evaluated against `data` if you also pass one. - **Save a template the agent can re-use** ("remember this layout for next time"): POST to `https://api.pdfzen.site/v402/templates` with `{ "slug": "my-thing", "html": "…", "css": "…", "sampleData": { … } }`. Save is **free** under x402 — only renders are paid. Caps: 100 templates per wallet, 256 KB per body. - **List templates this agent has saved**: GET `https://api.pdfzen.site/v402/templates` with the wallet's x402 auth header. - **Discover available tools via MCP** (Claude Desktop, Cursor, Goose, etc.): connect to `https://api.pdfzen.site/mcp` — JSON-RPC 2.0 over Streamable HTTP. Exposes `list_starters`, `get_starter`, `render_template_to_pdf`, `render_html_to_pdf`. Free tools (list/get) don't need payment; render tools return a 402 PaymentRequirement on first call, which the wallet runtime signs and replays. Output is always `application/pdf` bytes on success. Errors come back as `{ "error": { "code": "...", "message": "..." } }` JSON with the right HTTP status. See [/docs/x402](https://pdfzen.site/docs/x402) for the full error catalog. ## Agents and x402 - [Agent docs](https://pdfzen.site/docs/x402): Full guide to the x402 surface — `/v402/render/pdf`, `/v402/templates`, pricing, errors, and an Anthropic Tool Use schema. - [MCP server](https://api.pdfzen.site/mcp): Model Context Protocol endpoint exposing `list_starters`, `get_starter`, `render_template_to_pdf`, `render_html_to_pdf` as discoverable tools. POST with JSON-RPC 2.0. Render tools settle via x402 USDC on Base — pass an `X-PAYMENT` header signed by your wallet runtime; if missing, the tool returns the PaymentRequirement to sign. - [Public starter catalog](https://api.pdfzen.site/v1/starters): JSON listing of all 45 ready-to-render templates. No auth. - [Per-starter detail](https://api.pdfzen.site/v1/starters/invoice): Full body HTML + sample data shape for a given slug. Replace `invoice` with any other slug. - [x402 protocol spec](https://x402.org): The HTTP-402 payment standard pdfzen implements. Coinbase + Cloudflare collaboration. ## API reference (credit-based, human accounts) - [API reference](https://pdfzen.site/docs): Bearer-auth REST endpoints for render, templates, documents, webhooks, errors. - [Pricing model](https://pdfzen.site/docs#render): $0.005/render base, drops to $0.003/render above 10K/month and $0.002/render above 100K/month. First 100 MB of stored PDFs are free per workspace. ## Templates - [Browse all 45 starters](https://pdfzen.site/templates): Public gallery — invoices, contracts, certificates, resumes, lease agreements, lab reports, recipe cards, boarding passes, brochures, menus, conference badges, gift certificates, and more. - [Template index](https://pdfzen.site/templates): Same listing as the API endpoint above, formatted for browsers. ## Free tools (browser-based, no signup) - [Tools index](https://pdfzen.site/tools): Catalog of free PDF utilities. All processing happens client-side via WebAssembly — files never leave the user's browser. - [Merge PDFs](https://pdfzen.site/tools/merge-pdf): Combine multiple PDFs into one. Drag-and-drop to reorder. - [Split PDF](https://pdfzen.site/tools/split-pdf): Extract pages or break a PDF into chapter-sized chunks. - [Rotate PDF](https://pdfzen.site/tools/rotate-pdf): Rotate pages 90 / 180 / 270 degrees; all pages or a specific range. - [JPG to PDF](https://pdfzen.site/tools/jpg-to-pdf): Bundle JPG / PNG / WebP images into a single PDF, one image per page. - [Remove pages from PDF](https://pdfzen.site/tools/remove-pages): Delete specified pages from a PDF. - [Add page numbers to PDF](https://pdfzen.site/tools/add-page-numbers): Stamp page numbers (choose position, format, starting number). - [Watermark PDF](https://pdfzen.site/tools/watermark-pdf): Stamp diagonal text watermark — DRAFT, CONFIDENTIAL, etc. — on every page. Tune color, opacity, size, angle. - [PDF to JPG](https://pdfzen.site/tools/pdf-to-jpg): Render PDF pages as JPG images. - [PDF to PNG](https://pdfzen.site/tools/pdf-to-png): Render PDF pages as lossless PNG images. - [Extract text from PDF](https://pdfzen.site/tools/extract-text): Pull selectable text out as plain .txt. - [Reorder PDF pages](https://pdfzen.site/tools/reorder-pages): Move pages up and down to change the order. - [Add header & footer](https://pdfzen.site/tools/add-header-footer): Stamp custom text on the top / bottom of every page. - [Edit PDF metadata](https://pdfzen.site/tools/edit-metadata): Update title / author / subject / keywords. ## Marketing & policy - [Homepage](https://pdfzen.site/): Product overview, pricing headline, signup. - [Refund policy](https://pdfzen.site/legal/refund): 14-day money-back on unused credits, no questions asked. - [Terms of service](https://pdfzen.site/legal/terms) - [Privacy policy](https://pdfzen.site/legal/privacy) ## Sitemaps - [XML sitemap](https://pdfzen.site/sitemap.xml): Full list of public URLs (45 starters + marketing routes).