Templates
What a Druckling template contains, how its draft becomes immutable published versions, and how to read templates through the API.
A template is a document layout plus the data contract it expects. You design it in the visual editor, publish it, and then render documents from it by sending its slug and a JSON payload to POST /v1/documents.
What a template contains
Every template is one document with these parts:
- Page setup: paper size and orientation, margins in millimeters, a header and footer that repeat on every page, an optional first-page header (for letterheads) and an optional text watermark.
- Document settings: title and author (written to the PDF metadata), fonts, base text size, line spacing, default language, hyphenation, justification, text and accent colors, the currency the
moneyfilter uses, the PDF standard and e-invoicing. - Variables: the fields the payload can or must contain. They define the template's JSON Schema.
- Sample data: an example payload, used for previews and checked when you publish.
- Blocks: the content, in order.
- Translations: texts for languages other than the default one. See Languages.
Blocks
| Block | What it does |
|---|---|
| Text | A paragraph with template strings: bound values, bold, italic and links. |
| Heading | A level 1, 2 or 3 heading. |
| Table | Repeats one row per item of a list variable, with a repeating header, page-break rules, sorting and optional totals rows. |
| Image | An image from a fixed https URL or from an image variable. Shows a placeholder box when there's no image. |
| Chart | A bar or line chart over a list variable. |
| QR / Barcode | A QR code, Code 128, EAN-13 or Data Matrix code whose value is a template string. |
| Signature | A signature line with a label, an optional signer name and an optional date line. |
| Page no. | A page counter such as Page {page} of {total}, usually in the footer. |
| Divider | A horizontal rule. |
| Spacer | Vertical space, in points. |
| Page break | Starts a new page. |
| Box | A container with an optional fill and border, for notes and callouts. |
| Columns | Up to six side-by-side columns, each holding its own blocks. |
Every block also has style settings (alignment, size, weight, italic, color, font, space above and below, keep together on one page) and an optional visibility condition that shows it only when the payload meets it. See Conditional blocks.
Slugs
API requests identify a template by its slug, for example invoice-standard. Druckling derives the slug from the name when you create the template: it lowercases the name, removes accents, turns everything other than letters and digits into dashes and keeps at most 56 characters. Invoice — Standard (EU) becomes invoice-standard-eu. If the slug is taken, Druckling appends -2, -3 and so on.
A slug is 2 to 63 characters long, uses lowercase letters, digits and dashes, starts with a letter or digit, and is unique within the workspace. Test and live API keys see the same templates, so a slug works with both dr_test_… and dr_live_… keys.
Kinds
Each template has a kind: invoice, certificate, report, ticket, agreement, packing or custom. A template made from a starter takes the starter's kind; a blank template is custom. The kind only labels the template in the dashboard. It doesn't change how it renders, and the API doesn't return it.
Starters
Starters are ready-made templates with variables and sample data. Create a template from one in Templates › New template, which also offers a blank A4 page, a template built by Druck, the AI assistant, from an image or sketch, and Import from PDF.
| Slug | Name | What it is | In new workspaces |
|---|---|---|---|
invoice-standard | Invoice | A4 invoice with line items, totals and a payment QR code. | Created and published as version 1 |
course-certificate | Course certificate | Landscape A4 certificate with a signature line and a verification QR code. | Created as a draft |
quarterly-report | Quarterly report | Summary, revenue bar chart and KPI table. | Created as a draft |
event-ticket | Event ticket | Landscape A6 ticket with a scannable QR code. | Created as a draft |
rental-agreement | Rental agreement | Multi-page contract with clauses and two signature lines. | Created as a draft |
packing-slip | Packing slip | A5 slip with order items and a Code 128 barcode. | Created as a draft |
rechnung-zugferd | Rechnung (ZUGFeRD) | German EN 16931 e-invoice (ZUGFeRD / Factur-X, PDF/A-3b) with the §14 UStG details and a GiroCode. | Not created; add it from New template |
facture-factur-x | Facture (Factur-X) | French EN 16931 e-invoice (Factur-X, PDF/A-3b) with the mandatory mentions. | Not created; add it from New template |
A new workspace starts with the first six. Only invoice-standard is published, so it's the only one you can render right away; publish the others before you render them. The e-invoice starters are covered in E-invoicing.
Editing templates
Visual editor
Open a template under Templates and click Open editor. The left panel holds the Blocks palette, the Layers tree and the Data tab with variables and sample data. The right panel edits the selected Block, the Page and the Document. The canvas is rendered by the same Typst engine as the API, with your sample data, and a switch above it shows either the variable names or the sample values.
Test PDF renders the draft with its sample data into a PDF you can download. It doesn't create a document or count toward your plan.
Druck
The editor comes with Druck, the AI assistant. You can ask Druck for changes in plain language. Druck reads the draft, its variables and sample data, and it can:
- add, restyle, move and remove blocks, declare variables and fill in sample data,
- lay out the draft with the real engine to answer questions such as "will 40 line items fit on two pages?",
- check a payload against the template's schema,
- translate the template into another language,
- read this template's recent renders to explain a failure,
- rebuild a layout from an attached image, sketch or PDF.
Druck proposes changes as a card that you Apply or Discard. Nothing changes until you apply it, and applied changes land in the draft like your own edits.
Other ways to edit
- An AI agent can create, edit, preview and publish templates through the hosted MCP server with a Full access API key.
- Your own users can edit a template inside your product with the embedded editor.
The /v1 REST API reads templates but doesn't edit them.
Drafts, versions and publishing
A template has one editable draft and any number of published versions. Renders always use a version, never the draft.
The draft
The editor saves the draft continuously while you work. Each save applies a set of edit operations to a numbered revision of the draft and increments it. If someone else saved the draft since the revision your change was based on, the save is rejected with stale_revision (409). The editor handles this for you: it loads the newer draft and reapplies your changes on top. An agent working through the MCP server gets the error and has to re-read the draft before it retries.
Publishing
Click Publish in the editor (Publish changes once a version exists), optionally describe what changed, and confirm. The note can be up to 500 characters and shows in the template's Versions tab.
Publishing creates the next version number (1, 2, 3, …) as an immutable snapshot of the document, its JSON Schema and its required fields. Before it does, Druckling checks the draft:
- The draft has no validation errors. Warnings don't block publishing; see Validation issues.
- The sample data matches the template's variables.
- The draft renders with the sample data, including the checks of its PDF standard.
If a check fails, nothing is published and you get the reason: validation_failed (422) for the first two, render_failed (422) for the third, and stale_revision (409) if the draft changed while publishing.
A template's status is draft until it's published for the first time and published from then on, even while the draft has newer changes. latest_version is the newest version number, or null before the first publish.
Which version a render uses
POST /v1/documents and POST /v1/batches take an optional version: a version number, or "latest" (the default).
"latest"resolves when the request arrives, and the document records the number it used inversion. An asynchronous render keeps that number even if you publish again before it runs.- Editing the draft never changes what renders produce. Only publishing does, and only for requests that use
"latest". - Pinned versions keep working after you publish newer ones.
curl https://druckling-nine.vercel.app/v1/documents \
-H "Authorization: Bearer $DRUCKLING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "invoice-standard",
"version": 1,
"data": {
"invoice": { "number": "INV-2041", "due_date": "2026-11-22" },
"customer": { "name": "Northwind Ltd.", "address": "12 Pier St, Leeds" },
"line_items": [
{ "description": "Design system audit", "qty": 12, "rate": 180, "amount": 2160 }
],
"totals": { "subtotal": 2160, "tax": 172.8, "amount": 2332.8 }
}
}'Pin versions in production
Pin the version your integration was built against. You can then publish freely, and move the pin when your code sends what the new version expects, for example a field that became required.
Rendering a template that was never published fails with 404 not_found and field: "template", with the message Template quarterly-report has no published version yet; publish it first. A version number that doesn't exist fails with 404 not_found and field: "version", for example Template invoice-standard has no version 7. See Errors.
Validation issues
The editor checks the draft as you edit and lists the problems in the status menu above the canvas. Errors block publishing; warnings don't.
Errors include:
- a binding to a variable that isn't declared, such as
{{customer.phone}}, - template string syntax: an unclosed
{{, an unknown filter, more than one filter in a binding, or an unclosed**or*, - a table or chart over a variable that isn't a declared list, or an image bound to an undeclared variable,
- a visibility condition on an undeclared variable, or a comparison without a value,
- a variable declared twice, or two blocks with the same id,
- the rules of the chosen PDF standard, such as alt text on images for PDF/UA-1 and PDF/A-3a (see Accessible PDFs),
- e-invoicing settings that don't fit together, such as Factur-X without PDF/A-3 (see E-invoicing),
- translations that are too long or contain broken bindings.
Warnings include a binding to a whole object or list instead of one of its fields, a sort field or chart axis that isn't declared on the list, and texts that aren't translated yet (they print in the default language).
Template settings
Page and document settings are part of the draft, so a change takes effect for renders when you publish it.
| Setting | Where | Options |
|---|---|---|
| Paper | Page › Paper | A4, A5, A6, Letter, Legal or a 4 × 6 in label, portrait or landscape. |
| Margins, header and footer | Page | Margins in millimeters; header, footer and first-page header blocks; watermark. |
| PDF standard | Document › Output | Standard PDF, PDF/A-2b, PDF/A-3b, PDF/A-3a or PDF/UA-1, one per template. See Accessible PDFs. |
| E-invoice (EN 16931) | Document › Output | Factur-X / ZUGFeRD, XRechnung or Peppol BIS. See E-invoicing. |
| Currency | Document › Output | The default currency of the money filter (USD unless you change it). See Template strings. |
| Language | Document › Typography and the language switcher above the canvas | A default language plus up to 30 more. See Languages. |
Duplicating a template
Duplicate on the template page copies the current draft into a new template named after the original with (copy) appended, with the slug <slug>-copy (or -copy-2, …). The copy starts as an unpublished draft with no versions, so publish it before you render it. Documents rendered from the original stay with the original.
Templates in the API
Two read-only endpoints describe your templates. Both need the templates:read permission, which Full access keys have. A Render only key gets 403 forbidden. Create keys in Developers › API keys; see Authentication.
GET /v1/templateslists every template in the workspace, drafts included, most recently changed first. The list isn't paginated.GET /v1/templates/{slug}returns one template with itsjson_schemaandsample_data.
required_fields, language, languages, json_schema and sample_data describe the latest published version, or the draft for a template that was never published. Unpublished draft changes don't show up until you publish.
curl https://druckling-nine.vercel.app/v1/templates/invoice-standard \
-H "Authorization: Bearer $DRUCKLING_API_KEY"The response, with json_schema and sample_data shortened (the full schema is on Variables and schema):
{
"id": "tpl_3Hk9QmZ1xT7pLw2V",
"object": "template",
"slug": "invoice-standard",
"name": "Invoice",
"status": "published",
"latest_version": 1,
"required_fields": [
"invoice.number",
"invoice.due_date",
"customer.name",
"customer.address",
"line_items[].description",
"line_items[].qty",
"line_items[].rate",
"line_items[].amount",
"totals.subtotal",
"totals.amount"
],
"language": "en",
"languages": ["en"],
"updated_at": "2026-10-27T09:12:44.512Z",
"json_schema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"customer": {
"type": "object",
"properties": {
"name": { "type": "string" },
"address": { "type": "string" }
},
"required": ["name", "address"]
}
},
"required": ["invoice", "customer", "line_items", "totals"]
},
"sample_data": {
"customer": { "name": "Northwind Ltd.", "address": "12 Pier St, Leeds" }
}
}required_fields lists the required leaf fields. Fields of list items appear with [], as in line_items[].qty: each item must have them.