Templates
Save your HTML, CSS and page settings once, then send only the data for each document.
Using a template
Save your HTML once in the dashboard (under Templates), then send only templateId and the data for each document, instead of html. All other options (paper size, margins, passwords, screenshots, callbacks) work as usual. Every plan includes templates, from 3 on Free to 500 on Enterprise.
curl https://api.printpipe.io/v1/generate \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{
"templateId": "0199a0c2-3f4e-7b6a-9c1d-2e5f8a7b4c3d",
"data": {
"number": "2026-042",
"customer": { "name": "Acme Ltd" },
"items": [
{ "name": "Consulting", "qty": 3, "price": "€300.00" },
{ "name": "Support plan", "qty": 1, "price": "€90.00" }
],
"paid": true
}
}' --output invoice.pdfTemplates use Mustache syntax:
<h1>Invoice {{number}}</h1>
<p>{{customer.name}}</p>
<table>
{{#items}}
<tr><td>{{name}}</td><td>{{qty}}</td><td>{{price}}</td></tr>
{{/items}}
</table>
{{#paid}}<p>Paid, thank you!</p>{{/paid}}
{{^paid}}<p>Please pay within 14 days.</p>{{/paid}}- Styles belong in the HTML, in a
<style>block, so the template is one document you can open anywhere. The optional override CSS is added after them, so it wins, and may use values too, e.g.h1 { color: {{brandColor}}; }: one layout, several brands. - A request can bring its own override CSS too, without changing the template:
"css": "h1 { color: #0a7; }". It goes last, after the HTML's styles and the template's override CSS, so it wins. It is plain CSS, not filled with data, and works withhtmlas well. - Page settings saved with the template (paper, orientation, margins, background, screen or print CSS, scale) apply whenever it is used. A request can still set its own, e.g.
"landscape": false. {{name}}prints a value, HTML-escaped;{{{name}}}prints it unescaped, for HTML you trust. Nested values use dots:{{customer.name}}.{{#items}}…{{/items}}repeats for each item of a list ({{.}}is the item itself), shows once for an object ortrue, and is left out when the value is missing, false or empty.{{^items}}…{{/items}}is the opposite.- Format numbers, prices and dates in your data; templates contain no code.
- HTML and CSS together are up to 512 KB (load images from a URL), and a filled-in template up to 5 MB. An unknown id fails with error code 13, a template that can't be filled in with 14.
- Templates are stored until you delete them. The data you send and the documents you get are never stored.
Templates API
Everything the dashboard's Templates page does also works with your API key (X-API-Key or Authorization: Bearer), so you can keep templates in your own repository and deploy them from CI. Responses are JSON; errors use the codes from Errors.
| GET | /v1/templates | Your templates, and how many the plan allows. |
| POST | /v1/templates | Create one: name, html, and optionally css, options and sampleData. |
| GET | /v1/templates/:id | One template with its HTML, CSS, page settings and example data. |
| PUT | /v1/templates/:id | Replace it (same body as POST). |
| PATCH | /v1/templates/:id | Change only the fields you send, e.g. {"css": "…"}. |
| DELETE | /v1/templates/:id | Delete it. Requests with its templateId fail afterwards. |
| POST | /v1/templates/:id/duplicate | Copy it, optionally with {"name": "…"}. |
| POST | /v1/templates/preview | Free preview, stamped “Preview”: a draft (html, css, options, sampleData) or {"templateId": …}, with output "png" or "pdf". Up to 60 an hour. |
curl -X POST https://api.printpipe.io/v1/templates -H "X-API-Key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{
"name": "Invoice",
"html": "<h1>Invoice {{number}}</h1>",
"css": "h1 { color: {{accent}}; }",
"options": { "format": "A5", "landscape": true, "marginTop": 40 },
"sampleData": { "number": "2026-001", "accent": "#c4472f" }
}'options takes format, landscape, width + height (px), the four margins (px), printBackground, media and scale, with the same meaning as the parameters. API keys, billing and account settings stay in the dashboard.