Docs / Templates

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:

#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.

IdDocument
invoiceInvoice with line items, discount, tax, payments and a balance due.
quoteSales quote with line items, tax, terms and a signature block.
receiptPayment receipt with line items, tip, payment method and amount paid.
statementAccount statement with opening balance, transactions, ageing and closing balance.
reportMulti-page report with a cover, summary figures, charts and tables.
packing-slipPacking slip with ship-to, ordered and shipped quantities, and backorders.
certificateLandscape 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": [] }
}
FieldDescription
kindhtml, or docx / xlsx for Word and Excel templates.
htmlThe document body, with template language placeholders. No <html>, <head> or <body> tags needed.
cssExtra CSS on top of the print kit.
settingsPage setup: page_size, orientation, margin, font, heading_font, accent, page_numbers, header_text, footer_text. See print kit settings.
sample_dataExample JSON for the template. The dashboard preview uses it, and it documents the shape your code should send.
sourceHow it was made: blank, starter, ai or upload.
versionStarts 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 }
  }'
FieldRequiredDescription
htmlyes, unless from is setTemplate body. Up to 600,000 characters.
fromA template id to copy, such as "invoice". Use instead of html.
nameUp to 120 characters. Defaults to "Untitled template".
descriptionUp to 500 characters.
cssUp to 300,000 characters.
settingsPage settings. Invalid values are rejected.
sample_dataAny 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

PlanSaved templates
Every plan, including FreeUnlimited

Starters do not count. Creating a template over the limit returns plan_limit.