TemplatesBeta

Invoice templates – BlockTemplate JSON for XRechnung & ZUGFeRD

JSON-based PDF templates in the BlockTemplate format — nine block types, placeholders, design tokens and § 14 UStG-compliant presentation for XRechnung, ZUGFeRD and Peppol.

9 block types flowing into a PDF invoice

What is a template?

An invoice template is a JSON document with the fields version, name, page, body (required) and the optional fields header, footer, styles. On the/generate call, invoice data is merged into placeholders and a PDF (or PDF/A-3 with embedded ZUGFeRD XML) is produced.

9 block types

text, table, keyvalue, summary, image, spacer, line, qrcode, columns — all with a {type, data} envelope, nestable via columns.

Placeholders & conditions

Flat Mustache syntax: {{invoiceNumber}}, {{seller.name}}. Suffix {{field?}} = optional. The condition property renders blocks only when values are present.

Design tokens

page.colorScheme and page.fontSizes define named tokens. Blocks reference them via { token: 'primaryColor' } instead of hex values — one tenant, one color swap.

Hybrid-compliant

The template delivers the visual layer; for ZUGFeRD the structured EN-16931 XML is automatically embedded into the PDF/A-3. § 14 UStG mandatory fields are validated before rendering.

The 9 block types

Every block follows the envelope { type, data } and may carry an optional condition that hides the block when placeholders are empty.

typePurposeRequired fields in data
textText section with placeholders, style, color, alignmentcontent
tableData-bound table over lists (line items, tax rows)dataSource, columns
keyvalueLabel/value pairs — invoice header, customer data, payment infoitems[]
summaryTotals block with dynamic VAT rows and footer total— (typical: rows or dynamicRows)
imageLogo or graphic (URL, Base64 or placeholder)src
spacerVertical spacing in pointsheight
lineHorizontal divider with thickness and color
qrcodeQR code, e.g. SEPA giro code or payment linkcontent
columnsMulti-column layout, nestable blockscolumns[]

Placeholder reference

All fields of the Creator payload are available inside the template. Mark optionality with {{field?}}. Lists are bound via dataSource to table or summary blocks.

Invoice header

PlaceholderTypeExampleDescription
{{invoiceNumber}}stringINV-2026-042Invoice number (§ 14 UStG)
{{issueDate}}date2026-04-14Issue date
{{dueDate}}date2026-05-14Due date
{{currency}}stringEURISO 4217
{{subtotal}} / {{total}}number1500.00 / 1785.00Net resp. gross total

Seller / Buyer (identical structure)

PlaceholderTypeExampleDescription
{{seller.name}}, {{buyer.name}}stringACME GmbH / Kunde AGCompany name (required)
{{seller.street}}, {{buyer.street}}stringHauptstr. 1Street (required)
{{seller.postalCode}}, {{buyer.postalCode}}string10115Postal code (required)
{{seller.city}}, {{buyer.city}}stringBerlinCity (required)
{{seller.countryCode}}, {{buyer.countryCode}}stringDEISO 3166-1 alpha-2 (required)
{{seller.vatId?}}, {{buyer.vatId?}}stringDE123456789EU VAT ID, optional
{{seller.taxId?}}, {{buyer.taxId?}}string12/345/67890National tax number, optional
{{seller.bankAccount.iban?}}, {{buyer.bankAccount.iban?}}stringDE89…IBAN (seller: required for SEPA credit transfer; buyer: required for SEPA direct debit)
Additional fields on both: tradingName, additionalStreet, state, email, phone, website, bankAccount.bic/bankName/accountHolder — see placeholder reference.

Data sources for table / summary

PlaceholderTypeExampleDescription
{{items}}arrayLine items (dataSource for the table block)
{{taxSummary}}arrayTax rows (dataSource for summary.dynamicRows)
item.fieldanydescription, quantity, netAmount, …Column binding via the field prop in table.columns

Using a template

Templates are passed directly to /api/v1/invoice/{countryCode}/{format}/generate — either by templateId (UUID of a stored template) or inline via formatOptions.template. Priority: templateId > formatOptions.template> default.

Recommended

By templateId

Create once in the console or via pdf.templateCreate, then send only the UUID per request.

bash
1curl -X POST \
2 https://service.invoice-api.xhub.io/api/v1/invoice/de/zugferd/generate \
3 -H "Authorization: Bearer $XHUB_API_KEY" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "templateId": "b3c9a0d8-4f2e-4a1c-9e87-0d2f1a5b6c7d",
7 "invoice": { /* ... invoice payload (Creator API) ... */ }
8 }'
Ad-hoc

Inline BlockTemplate

Send the template JSON directly with the request — useful for tests, CI pipelines or dynamically generated layouts.

bash
1curl -X POST \
2 https://service.invoice-api.xhub.io/api/v1/invoice/de/zugferd/generate \
3 -H "Authorization: Bearer $XHUB_API_KEY" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "invoice": { /* ... */ },
7 "formatOptions": {
8 "template": { /* inline BlockTemplate JSON */ }
9 }
10 }'
Mandatory-field validation before rendering
Embedded fonts, PDF/A-3 for ZUGFeRD
Hybrid invoice: EN-16931 XML embedded automatically

Frequently asked questions

Ready to design your invoice?

Start from a system template, adjust logo and colors and render your first PDF in under 5 minutes.