Templates
Templates
A template is a reusable document design: HTML with placeholders, a little CSS, and page settings. You save it once and render it with different JSON as often as you like.
There are three ways to make one:
- Describe it. Generate a template from plain English.
- Start from a starter. Copy one of the seven built-in documents and change it.
- Write it. HTML and the template language, in the dashboard editor or through this API.
#Starter templates
Seven templates are built in and available to every account by id. Each one is translated into 32 languages: send a locale and the labels, dates and money follow.
| Id | Document |
|---|---|
invoice | Invoice with line items, discount, tax, payments and a balance due. |
quote | Sales quote with line items, tax, terms and a signature block. |
receipt | Payment receipt with line items, tip, payment method and amount paid. |
statement | Account statement with opening balance, transactions, ageing and closing balance. |
report | Multi-page report with a cover, summary figures, charts and tables. |
packing-slip | Packing slip with ship-to, ordered and shipped quantities, and backorders. |
certificate | Landscape certificate with recipient, description and signers. |
Render one directly with "template": "invoice". To see the data a starter expects, fetch it and read sample_data:
curl https://devilpdf.com/v1/templates/invoice \
-H "Authorization: Bearer $DEVILPDF_API_KEY"Starters are read-only. To change one, copy it into your account first.
curl https://devilpdf.com/v1/templates \
-H "Authorization: Bearer $DEVILPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "from": "invoice", "name": "Our invoice" }'#The template object
{
"object": "template",
"id": "tpl_8sK2mQx7Lp0aVn3RtYc1",
"name": "Packing slip",
"description": "Packing slip with ship-to address and a table of items.",
"kind": "html",
"settings": { "page_size": "Letter", "accent": "#0f766e", "page_numbers": true },
"source": "blank",
"starter": false,
"version": 3,
"created_at": "2026-03-10T09:12:44.102Z",
"updated_at": "2026-03-14T14:02:10.588Z",
"html": "<header class=\"doc-head\">...</header>",
"css": "",
"sample_data": { "order": { "number": "SO-1182" }, "items": [] }
}| Field | Description |
|---|---|
kind | html, or docx / xlsx for Word and Excel templates. |
html | The document body, with template language placeholders. No <html>, <head> or <body> tags needed. |
css | Extra CSS on top of the print kit. |
settings | Page setup: page_size, orientation, margin, font, heading_font, accent, page_numbers, header_text, footer_text. See print kit settings. |
sample_data | Example JSON for the template. The dashboard preview uses it, and it documents the shape your code should send. |
source | How it was made: blank, starter, ai or upload. |
version | Starts at 1 and goes up by one on every update. |
#Create a template
curl https://devilpdf.com/v1/templates \
-H "Authorization: Bearer $DEVILPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Receipt",
"html": "<h1 class=\"doc-title\">Receipt</h1><p>Thanks, {{ customer.name }}.</p><div class=\"totals\"><div class=\"row grand\"><span>Paid</span><span>{{ amount | money }}</span></div></div>",
"settings": { "page_size": "A5", "accent": "#e11d48" },
"sample_data": { "customer": { "name": "Dana" }, "amount": 42.5 }
}'| Field | Required | Description |
|---|---|---|
html | yes, unless from is set | Template body. Up to 600,000 characters. |
from | A template id to copy, such as "invoice". Use instead of html. | |
name | Up to 120 characters. Defaults to "Untitled template". | |
description | Up to 500 characters. | |
css | Up to 300,000 characters. | |
settings | Page settings. Invalid values are rejected. | |
sample_data | Any JSON. |
The template is checked when you save it. A syntax error returns template_error with the line and col.
#Update a template
PATCH with only the fields you want to change. Every update bumps version.
curl -X PATCH https://devilpdf.com/v1/templates/tpl_8sK2mQx7Lp0aVn3RtYc1 \
-H "Authorization: Bearer $DEVILPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "settings": { "page_size": "A4", "page_numbers": true } }'settings is replaced as a whole, not merged. Send every setting you want to keep.
Changes apply to the next render. Documents already generated are not affected.
#List templates
curl https://devilpdf.com/v1/templates \
-H "Authorization: Bearer $DEVILPDF_API_KEY"Returns your templates, most recently updated first, followed by the starters. Add ?starters=false to leave the starters out. The list omits html, css and sample_data; fetch a single template to get them.
#Get, duplicate, delete
# Get one template, with html, css and sample_data
curl https://devilpdf.com/v1/templates/tpl_8sK2mQx7Lp0aVn3RtYc1 \
-H "Authorization: Bearer $DEVILPDF_API_KEY"
# Duplicate
curl -X POST https://devilpdf.com/v1/templates/tpl_8sK2mQx7Lp0aVn3RtYc1/duplicate \
-H "Authorization: Bearer $DEVILPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Receipt (French)" }'
# Delete
curl -X DELETE https://devilpdf.com/v1/templates/tpl_8sK2mQx7Lp0aVn3RtYc1 \
-H "Authorization: Bearer $DEVILPDF_API_KEY"Rendering a deleted template returns not_found.
#Validate without saving
POST /v1/templates/validate checks html and settings and returns { "valid": true }, or a template_error with the position of the problem. Use it in CI if you keep templates in your repository.
#Template limits
| Plan | Saved templates |
|---|---|
| Every plan, including Free | Unlimited |
Starters do not count. Creating a template over the limit returns plan_limit.