Skip to content

Component templates

A component template describes a document as a tree of JSON components (containers, columns, text, rich text, images, lists, tables, dividers, spacers and page breaks), each bound to a value in your data. Nothing in it runs: text is never read as a template expression, and data values are inserted as text unless a rich text component reads them as HTML.

Choose components over Handlebars templates when a program generates the document, or when you want no code in the template at all. Scripts and helpers.js only run in Handlebars templates.

Studio’s visual editor edits the same tree on its pages: a new template with Start with set to Blank page, Ready-made starter or Layout from JSON data is a component template. AI assistants can build them through the MCP server. This page is the JSON reference, for when a program writes the tree.

You build a heading, a table of items and a “Paid” badge, then preview, publish and render it.

Replace YOUR_API_KEY in the examples with an API key with the template:write, template:read, template:publish, render:create and render:read scopes. The client libraries render documents but do not create templates, so steps 2 to 4 use curl.

Save your data as order.json:

order.json
{
"order": { "number": "A-1042", "paid": true },
"lines": [
{ "name": "Desk lamp", "price": 39.9 },
{ "name": "Bulb, 2 pack", "price": 6.5 }
]
}

The composition is the template’s body. A root container holds a text bound to the order number, a table with one row per line, and a badge shown only when the order is paid:

composition
{
"root": {
"type": "container",
"style": {
"display": "flex",
"flexDirection": "column",
"gap": 16,
"padding": 24
},
"children": [
{
"type": "text",
"text": { "path": ["order", "number"], "prefix": "Order " },
"style": { "fontSize": 20, "fontWeight": 700 }
},
{
"type": "table",
"source": { "path": ["lines"] },
"columns": [
{ "id": "name", "header": "Item", "value": { "path": ["name"] } },
{
"id": "price",
"header": "Price",
"value": {
"path": ["price"],
"format": { "type": "currency", "currency": "EUR" }
}
}
]
},
{
"type": "text",
"text": "Paid",
"visibleWhen": { "path": ["order", "paid"], "operator": "truthy" }
}
]
}
}

Inside the table, paths are relative to each line, so ["name"] is the line’s name.

Send the composition in the draft’s content, next to its page settings (the same fields as page.json):

Terminal window
curl https://app.typefold.dev/v1/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"name": "Order confirmation",
"content": {
"composition": { "root": { ... } },
"settings": {
"pageSize": { "widthMm": 210, "heightMm": 297 },
"margins": { "topMm": 10, "rightMm": 10, "bottomMm": 10, "leftMm": 10 }
}
}
}'

Replace { ... } with the root from step 1. The response is the new template with draftRevision 1. Save its id:

Terminal window
export TEMPLATE_ID='paste-the-id-here'
Terminal window
curl https://app.typefold.dev/v1/templates/$TEMPLATE_ID/preview \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d "{ \"data\": $(cat order.json) }" \
--fail-with-body -o preview.pdf

preview.pdf shows “Order A-1042”, a two-row table with prices such as “€39.90”, and the “Paid” badge. Preview again with "paid": false and the badge disappears.

The template also opens in Studio’s visual editor. To see it with your data there, add order.json as a workspace file and pick it under Sample data in the Data tab.

Renders by name use the newest published version:

Terminal window
curl https://app.typefold.dev/v1/templates/$TEMPLATE_ID/versions \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{ "expectedRevision": 1 }'

Render the template by name with the Reports API and save order.pdf:

Terminal window
curl "https://app.typefold.dev/v1/reports/render" \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
--fail-with-body -o order.pdf \
-d "{
\"format\": \"pdf\",
\"template\": { \"name\": \"Order confirmation\" },
\"data\": $(cat order.json)
}"

To render a specific version in the background, use the Renders API.

Field Type Description
root object Required. The top component, usually a container.
components object Up to 100 reusable components by ID.
stylesheets string[] Up to 20 workspace stylesheet paths from the template’s folder, applied in order.
theme object Colours, spacing steps, fonts and text styles that components use by name. See theme.
header object or string The page header: components, or Handlebars. See headers and footers.
footer object or string The page footer, like header.

The visual editor edits all of these. In Studio’s code editor, each part has its own file:

  • composition.json holds only root.
  • Page header and Page footer hold header and footer: components as JSON, or Handlebars as written.
  • Template files above the preview lists the folder’s stylesheets; tick the ones to apply.
  • components and theme have no file there, and saving keeps them unchanged. Edit the theme from Brand in the visual editor’s page settings, or either one through the API (PUT /v1/templates/{id}/draft).

Every component has a type and these optional fields:

Field Type Description
id string Names the component in its tree. See ids and names.
name string A display name for editors, 1 to 200 characters. It never appears in the document.
editor object Editing state, locked and hidden, each true or false. It never changes the document. See below.
textStyle string A text style from the theme. style overrides what it sets.
style object CSS properties in camelCase, each a value or a binding. See styling.
className string Up to 1,000 characters of space-separated classes from the template’s stylesheets.
visibleWhen object A condition. When it is false, the component and its children are left out.
keepTogether boolean true keeps the component on one page. See page breaks. Not on image.
frame object Only directly inside a fixedSection: where the component sits.

A pageBreak takes only id, name, editor and visibleWhen.

editor is for editing tools: locked: true keeps a component from being moved or deleted while editing, and hidden: true leaves it out of the editing view. Rendered documents always include it; use visibleWhen to leave a component out of the document.

Groups other components. Lay them out with CSS in style.

Field Type Description
children array Up to 1,000 child components. Leave it out for an empty box drawn with style.
tag string What the box is, such as a list or a section. See tags and alt text.
Field Type Description
text value Required. A literal, a binding, or mixed text.
tag string What the text is, such as a heading. See tags and alt text.

Text with paragraphs, line breaks, bold, italic, underline, links and lists, written as HTML.

Field Type Description
html value Required. HTML as a literal string, a binding, or mixed text parts.
{
"type": "richText",
"html": "<p>Payment is due in <strong>30 days</strong>.<br>Questions? <a href=\"mailto:[email protected]\">Write to us</a>.</p>"
}

Only these elements are kept: p, br, strong, b, em, i, u, a, ul, ol and li. A div becomes a paragraph. Every other element keeps only its text, and script, style and similar elements are dropped with their contents. Attributes are dropped, except a link’s href to an http, https or mailto address.

Literal strings are HTML. A bound value is inserted as text, so data cannot add formatting or links. Add "as": "html" to a binding to read its value as HTML, such as a rich text content field:

{
"type": "richText",
"html": { "path": ["$content", "terms"], "as": "html", "fallback": "" }
}

To format a value from the data, put it between literal tags in parts:

{
"type": "richText",
"html": {
"parts": [
"Due on <strong>",
{ "path": ["invoice", "dueDate"], "format": { "type": "date" } },
"</strong>."
]
}
}

Paragraphs and lists are spaced and indented as in a browser, without space before the first or after the last. Links are blue and underlined. style and className apply to the whole block; to restyle its elements, use a stylesheet class, such as .terms a { color: inherit; }.

Field Type Description
assetId string or binding Required. The ID of an uploaded image, or a binding that selects one.
alt value What the image shows, for screen readers. See tags and alt text.
decorative boolean true for an image that is only decoration, which screen readers skip.
width number Width in CSS pixels, above 0.
height number Height in CSS pixels, above 0.

To get an ID, add the image to the workspace in Studio and open it: the ID is shown as Asset ID. Or upload it with POST /v1/assets (see the API reference). Publishing copies the image into the version, so deleting it later does not change published versions.

A binding in assetId can only select an image the template already names literally, for example in another image component. Anything else fails with 400 ASSET_INVALID. To pick one of several logos, add one image per logo and show the right one with visibleWhen and equals.

Renders its children once for each item of an array. Inside, bindings read from the current item.

Field Type Description
source data source Required. The path of the array.
children array Required. Up to 1,000 components rendered for each item.
empty array Up to 1,000 components rendered instead when the array has no items.
tag string ul or ol makes the items a list. See tags and alt text.

The repeat is a flex column, and each item gets its own container. A source that is missing or null counts as empty; any other value that is not an array fails with 400 BAD_REQUEST.

Renders a header row, one row per item of an array, and optional totals rows.

Field Type Default Description
source data source Required. The path of the array; each item becomes a row.
columns array Required. 1 to 30 columns, described below.
showHeader boolean true false leaves out the header row.
repeatHeader boolean true Draws the header row again at the top of each page the table continues on.
headerTextStyle string A text style for header cells, under headerStyle.
headerStyle object Style for header cells, applied last.
cellStyle object Style for every cell.
emptyText string Up to 10,000 characters shown in one full-width row when the array is empty.
totals array 1 to 20 totals rows, such as a subtotal and a total.

Each column has:

Field Type Description
id string Required. Unique in the table. Up to 128 letters, digits, _ and -, starting with a letter or digit.
header string or binding Required. Header text up to 1,000 characters (can be empty), or a binding read from the table’s data.
value value Required. What the cell shows. Bindings read from the row’s item.
width number Width in CSS pixels, above 0 and up to 2,000. Without it, the table sizes the column.
style object Style for this column’s cells.

Default look and behaviour:

  • The table spans the full width with collapsed borders.
  • Cells have 6px padding, a 1px #d1d5db border and left-aligned text. Header cells are semibold on #f3f4f6.
  • cellStyle applies first, then the column’s style, then headerTextStyle and headerStyle on header cells.
  • A row is never split across a page break, and the header row repeats on every page.
  • Without emptyText, an empty array leaves only the header row and the totals rows.

Set column widths with width, not a percentage in style: percentage cell widths can clip the contents.

Totals rows end the table with values such as a subtotal, the tax and the total. They are drawn once, after the last row, not on every page, and stay together on one page:

{
"type": "table",
"source": { "path": ["lines"] },
"columns": [
{ "id": "item", "header": "Item", "value": { "path": ["name"] } },
{ "id": "qty", "header": "Qty", "value": { "path": ["qty"] } },
{
"id": "amount",
"header": "Amount",
"value": { "path": ["amount"], "format": { "type": "currency", "currency": "EUR" } },
"style": { "textAlign": "right" }
}
],
"totals": [
{
"id": "total",
"cells": {
"item": { "value": "Total", "span": 2 },
"amount": {
"value": {
"aggregate": "sum",
"source": { "path": ["lines"] },
"field": ["amount"],
"format": { "type": "currency", "currency": "EUR" }
}
}
}
}
]
}
Field Type Description
id string Required. Unique among the table’s totals rows, in the same format as a column id.
cells object Required. At least one cell, by column id.
name string A display name for editors, 1 to 200 characters.
style object Style for the row’s cells.
visibleWhen object A condition. When it is false, the row is left out, such as an unused discount.

Each cell has:

Field Type Description
value value Required. What the cell shows. Bindings read the table’s data, not a row’s item.
span integer 2 to 30 columns to cover, from the cell’s own column to the right.
style object Style for this cell.

A cell can add up the table’s rows itself with a sum, as above, or show a total your data already has with a binding such as { "path": ["total"] }.

  • A column without a cell, and not covered by a span, gets an empty cell.
  • Totals cells are semibold. cellStyle applies first, then the column’s style, the row’s style and the cell’s style.
  • A cell naming a column the table does not have, cells covering the same column, a span past the last column, or a row id used twice fails the save with 400 BAD_REQUEST.

Places 2 to 4 components side by side, one per column. Columns never stack: a page always shows them in one row.

Field Type Default Description
children array Required. 2 to 4 components, one per column, left to right. Usually containers.
widths number[] equal Each column’s share of the row, one per child. [2, 1] makes the first column twice as wide.
gap number 16 Space between the columns in CSS pixels, 0 to 500.
align string top Where shorter columns sit: top, center, bottom, or stretch to make every column as tall.
{
"type": "columns",
"widths": [2, 1],
"children": [
{
"type": "container",
"children": [
{ "type": "text", "text": "Bill to" },
{ "type": "text", "text": { "path": ["customer", "name"] } }
]
},
{ "type": "text", "text": { "path": ["invoice", "date"] } }
]
}

A container in a column stacks its children top to bottom, unless its style sets display. A column keeps its share whatever it holds: a word longer than the column wraps. A column hidden with visibleWhen is left out, and the others share the row. To give a column a fixed width, set flex in its own style, such as "flex": "0 0 120px" for a 120px logo column.

A bulleted or numbered list. Give it fixed items, or a source array with one item per entry.

Field Type Default Description
items array 1 to 1,000 values, one item each.
source data source The path of an array. Each entry becomes an item.
text value With source: what each item shows. Bindings read from the entry.
children array With source: up to 1,000 components shown in each item, instead of text.
empty array With source: up to 1,000 components shown instead when the array has no entries.
marker string disc disc, circle, square or none for bullets; decimal, lower-alpha, upper-alpha, lower-roman or upper-roman for numbers.
start integer 1 The first number of a numbered list, 0 to 1,000,000.
itemStyle object Style for every item, such as { "marginBottom": 4 }.
{
"type": "list",
"marker": "decimal",
"source": { "path": ["steps"] },
"text": { "path": ["title"] }
}

Without text or children, each entry of source is shown as it is, so an array of strings needs nothing else. An entry that is an object, an array or null then fails with 400 BAD_REQUEST. A source that is missing or null counts as empty, as in a repeat.

The list is indented 40px, as in HTML, with the markers in the indent. Change it with paddingLeft in style. A list is tagged as a list for PDF/UA by itself.

A horizontal line across its parent.

Field Type Default Description
color string #d1d5db A hex colour such as #202830.
thickness number 1 In CSS pixels, above 0 and up to 50.
lineStyle string solid solid, dashed, dotted or double. A double line needs a thickness of 3 or more.

Add space around it with margin in style, such as { "margin": "12px 0" }.

Empty space of a fixed height.

Field Type Description
height number Required. In CSS pixels, above 0 and up to 2,000.

Dividers and spacers are decoration: screen readers skip them.

Places each child at an exact position, measured in millimetres or points, instead of one after another. Use it for tickets, vouchers, labels and forms printed on pre-made paper.

Field Type Default Description
children array Up to 1,000 components, each with a frame.
unit string mm mm or pt (1/72 inch), for the section’s size and every frame in it.
placement string flow flow places the section among the other components. everyPage draws it on every page.
height number Required with flow: the section’s height. Its children take no space of their own.
width number With flow: the section’s width. Without it, the section is as wide as its parent.
tag string What the section is, such as section. See tags and alt text.

Each child’s frame has:

Field Type Description
x number Required. From the section’s left edge, in the section’s unit. Can be negative.
y number Required. From the section’s top edge.
width number Above 0. Without it, the child is as wide as its content, wrapping at the section’s right edge.
height number Above 0. Without it, the child is as tall as its content.
{
"type": "fixedSection",
"height": 60,
"style": { "border": "0.3mm solid #202830" },
"children": [
{
"type": "image",
"assetId": "logo",
"alt": "Northline logo",
"frame": { "x": 5, "y": 5, "width": 40, "height": 10 }
},
{
"type": "text",
"text": { "path": ["ticket", "code"] },
"style": { "fontSize": 18, "fontWeight": 700 },
"frame": { "x": 120, "y": 5, "width": 60 }
},
{
"type": "text",
"text": { "parts": [{ "path": ["from"] }, " to ", { "path": ["to"] }] },
"frame": { "x": 5, "y": 30 }
}
]
}
  • Positions count from inside the section’s border, so a border moves the children by its width.
  • A child can be any component, including a repeat or table that flows inside its frame. Content larger than its frame still shows unless the child’s style sets "overflow": "hidden".
  • Children are drawn in order, so a later child covers an earlier one where they overlap. Screen readers also read them in this order: list them as they should be read.
  • A flow section is never split across a page break. When it does not fit on the rest of a page, it moves to the next page.
  • An everyPage section covers each page inside its margins, so x and y count from the margins’ top-left corner. Anything outside the margins is not drawn. Put pageNumber and pageCount in it to number every page.
  • In a header or footer, a section uses flow: the band is drawn on every page already.
  • Keep a flow section’s width within the margins: a wider section makes the whole page be drawn smaller to fit the paper.
  • Positions are rounded to whole CSS pixels (0.75 pt, about 0.26 mm).

Starts whatever follows it on a new page. See page breaks.

{ "type": "pageBreak" }

Renders a reusable component.

Field Type Description
componentId string Required. The key of the reusable component.
data data source Where the component reads its data. Without it, it reads the caller’s data.

pageNumber shows the number of the page it is drawn on, and pageCount the number of pages in the document. Use them in headers and footers, or in a fixedSection drawn on every page.

Field Type Default Description
format string decimal How the number is written, such as upper-roman. See counter styles.

Page numbers count every page of the document, also when pageRanges keeps only some of them.

A bar, line or pie chart of an array: one bar, point or slice per item.

Field Type Default Description
chart string Required. bar, line or pie.
source data source Required. The path of the array.
label value Required. Each item’s name on the axis, or its slice’s name in the legend. Bindings read from the item.
series array Required. 1 to 12 series, described below. A pie takes one.
width number 480 Width in CSS pixels, above 0 and up to 2,000.
height number 270 Height in CSS pixels, above 0 and up to 2,000.
colors array Up to 24 colours for series without their own and for a pie’s slices, in order. Each a colour, a theme colour or a binding.
horizontal boolean false Bar charts: bars run left to right, with the labels down the side.
stacked boolean false Bar charts: each item’s series stack in one bar, positive values up and negative values down.
categoryAxis object Bar and line charts: title, written along the axis with the labels.
valueAxis object Bar and line charts: title, min, max, and gridLines (false leaves out the lines across the plot).
legend string see below top, bottom, right or none.
valueLabels boolean false Writes each value on its bar or point (a stack’s total on stacked bars), or each slice’s share on a pie.
format object How values are written: a number, currency or percent format.
alt value from data What the chart shows, for screen readers. Without it, the chart describes its data.
empty array Up to 1,000 components shown instead of the chart when the array has no items.

Each series has:

Field Type Description
name string Required. 1 to 200 characters, shown in the legend and the chart’s description.
value data source Required. The path of the number in each item.
color string A colour, such as #1f4fd1, a theme colour, or a binding to one. Pies take colours from colors.
{
"type": "chart",
"id": "monthly-sales",
"chart": "bar",
"source": { "path": ["months"] },
"label": { "path": ["name"] },
"series": [
{ "name": "Revenue", "value": { "path": ["revenue"] } },
{ "name": "Costs", "value": { "path": ["costs"] }, "color": "#9ca3af" }
],
"format": { "type": "currency", "currency": "EUR", "maximumFractionDigits": 0 },
"valueAxis": { "title": "Amount" }
}

How it is drawn:

  • A value is a number or a string holding one, such as "1250.50". A missing, null or empty value leaves a gap: no bar, a break in the line, no slice. Anything else fails with 400 BAD_REQUEST naming the item. A pie’s values must be 0 or more.
  • The value axis starts at 0 unless the data goes below it, and its ticks fall on round numbers. min and max set the range; bars and lines past it are cut off.
  • Labels that would overlap are slanted, and only every few are written when there are many. A long label is shortened with ….
  • The legend is at the bottom when there are several series, and on the right of a pie. A single-series bar or line chart has none.
  • Without colors, series and slices take the default palette, which starts with #2563eb, #f97316, #16a34a and #dc2626. A colour can come from the theme, such as { "color": "brand" }, or be bound like a style value, such as a colour content field: { "path": ["$content", "brandColor"], "fallback": "#2563eb" }.
  • Text uses the chart’s fontFamily, fontSize and color from its textStyle and style: a family your stylesheets declare or a bundled font. Without them it is FreeSans at 11px in #374151. A character no font covers is left out of the chart.
  • A chart draws at most 2,000 items.

The chart is drawn as an image, so the same data always gives the same page. In a PDF/UA document it is a figure, described by alt, or by a summary of its data, such as “Bar chart of Revenue and Costs: January: Revenue €12,400, Costs €8,100; …”. The summary is in English and names at most 50 items; write alt for another language or a shorter description.

Draws a value as a sharp QR code or barcode image.

{
"type": "qrCode",
"value": { "parts": ["https://example.com/pay/", { "path": ["invoice", "number"] }] },
"widthMm": 25
}
Field Type Description
value value Required. What the code encodes: a literal, a binding, or mixed text.
symbology string The kind of code. qrcode for qrCode and code128 for barcode unless set. See the list below.
options object Up to 50 encoder options, such as includetext, eclevel or barcolor. See below.
alt value What screen readers read. The encoded value unless set.
widthMm number Width in millimetres, above 0 and up to 1,000.
heightMm number Height in millimetres, above 0 and up to 1,000.

Set widthMm or heightMm, and the other keeps the code’s shape. With neither, the code has its natural size, about 25 to 30 mm for a short QR code. With both, the code keeps its shape and is centred in that box, since a stretched QR code does not scan. To stretch a linear barcode to the box, add "objectFit": "fill" to its style, or set the height option for taller or shorter bars.

symbology takes the same names as the qrCode and barcode helpers of HTML templates, including ean13, ean8, upca, upce, code39, code93, interleaved2of5, itf14, gs1-128, datamatrix, pdf417, azteccode, maxicode, microqrcode and swissqrcode, and about a hundred more. An unknown name fails the save with 400 BAD_REQUEST.

options are the encoder’s own, with string, number or boolean values:

Option Example Effect
includetext true Prints the value under a barcode.
eclevel "H" QR code error correction: L, M (default), Q or H.
height 8 Taller or shorter bars on a linear barcode, compared with its width.
barcolor "1F2937" Colour of the bars, as hex RGB without #. backgroundcolor fills behind.
paddingwidth 4 Space around the code, left and right; paddingheight for top and bottom.
rotate "R" Turns the code: N, R (right), L (left) or I (upside down).

Each option name is letters and digits. bcid and text are refused: set symbology and value instead.

The code is an image tagged as a figure, so PDF/UA renders read its alt. A preview or render fails with 400 BAD_REQUEST, naming the code by its id when it has one, when the value is empty, longer than 8,000 characters, or one the symbology cannot encode, such as too few digits for an EAN-13:

{ "code": "BAD_REQUEST", "message": "Barcode \"ean\": EAN-13 must be 12 or 13 digits" }

Codes are drawn within the template’s time limit, the same as the helpers in an HTML template: about 400 short QR codes per render, and fewer for long values. Past it, the render fails with 400 LIMIT_EXCEEDED. The same value with the same options is drawn once however often it appears.

A field the reader fills in their PDF viewer: a text box, a check box, a drop-down list, a button or a place to sign. The block is a box of the field’s size, and the field covers the inside of its border. Draw the border and background with style.

{
"type": "container",
"style": { "display": "flex", "gap": 8, "alignItems": "center" },
"children": [
{ "type": "text", "text": "Name" },
{
"type": "formField",
"fieldType": "text",
"fieldName": "name",
"width": 200,
"height": 24,
"value": { "path": ["customer", "name"], "fallback": "" },
"style": { "border": "1px solid #9ca3af" }
}
]
}
Field Type Description
fieldType string Required. text, checkbox, combo, button or signature. See the table below.
fieldName value Required. The name a submitted form sends the value under, unique in the document.
width number Required. Width in CSS pixels, above 0 and up to 2,000.
height number Required. Height in CSS pixels, above 0 and up to 2,000.
label value What a screen reader announces, and a button’s caption. Without it, the field name is used.
readOnly boolean true stops the reader from changing the field.
required boolean true marks the field as required.
noExport boolean true leaves the field out when the form is submitted.

fieldName and label are values, so a field in a repeat can take a name from each item, such as { "parts": ["quantity_", { "path": ["sku"] }] }. A field name that resolves to an empty text, or to a name another field already has, fails with 400 BAD_REQUEST. The component’s name stays its display name for editors.

Each field type takes these fields too:

fieldType Adds Fields
text A text box. value, defaultValue, multiline, password, inputFormat, and the text fields.
checkbox A check box. value, defaultValue, checkStyle (check or square), color.
combo A drop-down list. items (required), value, defaultValue, and the text fields.
button A push button that submits or resets the form. action (required), url, submitFormat, submitMethod, includeEmptyFields, and the text fields.
signature An empty signature field the reader signs in the viewer. None.
  • value is what the field starts with, and defaultValue what a reset restores. Both are values, so they can come from the data. A check box is ticked unless its value is false, 0, an empty text, "false", "0", "off" or "no".
  • multiline and password set to true allow several lines, or hide what the reader types.
  • items lists the choices, as up to 500 texts or the path of an array in the data, such as { "path": ["plans"] }.
  • action is submit or reset. submit sends the form to url (required for it) as submitFormat fdf (the default), xfdf, html or pdf; an html form can set submitMethod to get instead of post. includeEmptyFields set to true also sends fields without a value. reset restores every field’s defaultValue.
  • The text fields are fontFamily, one of the 14 standard PDF fonts such as Helvetica (the default), Times-Roman or Courier; fontSize in CSS pixels, which the viewer fits to the field without it; color as #rrggbb or #rgb; and textAlign, left (the default), center or right.

inputFormat formats what the reader types into a text field, in viewers that run form scripts, such as Adobe Acrobat Reader:

type Fields
date mask (required): a pattern such as dd/mm/yyyy, where mm is the month.
time mask (required): HH:mm, hh:mm, HH:mm:ss or hh:mm:ss.
number fractionalDigits (0 to 10, default 0), thousandsSeparator, negativeStyle (MinusBlack, the default, Red, ParensBlack or ParensRed), currency (a symbol such as €) and currencyBefore (false puts the symbol after the number).
percent fractionalDigits and thousandsSeparator.
zip, zipPlus4, phone, ssn None. A US ZIP code, ZIP+4, phone number or Social Security number.
{
"type": "formField",
"fieldType": "text",
"fieldName": "amount",
"width": 120,
"height": 24,
"textAlign": "right",
"inputFormat": {
"type": "number",
"fractionalDigits": 2,
"thousandsSeparator": true,
"currency": "€"
}
}

Form fields work as in HTML templates:

  • A PDF/A document cannot have form fields: the render fails with UNSUPPORTED_FEATURE.
  • In a PDF/UA document, each field is tagged as a form field and announced with its label.
  • A field cannot be in a header or footer, which repeats on every page: the render fails with 400 BAD_REQUEST.
  • Viewers draw the field’s value themselves, so an image of the page shows the block’s own border and background, and a check box’s mark, but not typed text.

Where the document’s digital signature shows. When the template or the request signs the PDF with a certificate, the signature’s visible field covers the inside of this block’s border, on the page the block lands on. Its children draw what the field shows, such as the signer’s name or a stamp.

{
"type": "certificateSignature",
"width": 240,
"height": 80,
"style": { "border": "1px solid #202830", "padding": 8 },
"children": [{ "type": "text", "text": "Digitally signed by Northline Studio" }]
}
Field Type Description
width number Required. Width in CSS pixels, with padding and border, above 0 and up to 2,000.
height number Required. Height in CSS pixels, with padding and border, above 0 and up to 2,000.
children array Up to 1,000 components drawn inside, such as text or an image.
  • The block is never split across a page break.
  • It places the signature in place of the settings’ and the request’s field. With several blocks, the first one in the document places it.
  • Without a signature, the block only draws its children.
  • Like form fields, it cannot be in a header or footer.

Content flows onto as many pages as it needs. Two things change where pages end:

  • A pageBreak starts the next component on a new page. A page break with nothing before it, or nothing after it, adds no blank page, and two page breaks in a row make one break. To start each item of a repeat on its own page, such as one ticket per page, end the repeat’s children with a pageBreak; what follows the repeat then starts on a new page too. Show a page break only for some data with visibleWhen. Between components side by side, in a container with "flexDirection": "row", or in a header or footer, a page break does nothing.
  • "keepTogether": true moves a component that would be split by the end of a page to the next page, whole: a section with its heading, a paragraph, a whole table. A component taller than a page is still split. Like a tag, it makes the component a block on its own line unless its style or classes set display.
{
"type": "container",
"tag": "section",
"keepTogether": true,
"children": [
{ "type": "text", "tag": "h2", "text": "Payment" },
{ "type": "text", "tag": "p", "text": { "path": ["invoice", "terms"] } }
]
}

Define a block once under components, next to root, and use it anywhere with a component. The key is its ID: up to 128 letters, digits, _ and -, starting with a letter or digit. Each has a name (1 to 200 characters) and a root component.

{
"root": {
"type": "component",
"componentId": "address",
"data": { "path": ["billing"] }
},
"components": {
"address": {
"name": "Postal address",
"root": {
"type": "container",
"children": [
{ "type": "text", "text": { "path": ["name"] } },
{ "type": "text", "text": { "path": ["street"] } },
{ "type": "text", "text": { "path": ["city"] } }
]
}
}
}
}

Reusable components can use each other, but not themselves, directly or indirectly. An unknown componentId, a circular reference, or data pointing at a missing value fails the preview or render with 400 BAD_REQUEST.

Give a component an id to refer to it later, and a name to show people what it is:

{
"type": "text",
"id": "total",
"name": "Grand total",
"text": { "path": ["total"] }
}

An id has up to 128 letters, digits, _ and -, and starts with a letter or digit. It is unique in its tree: root is one tree, and each reusable component’s root is another. So a reusable component can use the same ids as the template it is placed in, or as another reusable component. Saving a draft with an id used twice in one tree fails with 400 BAD_REQUEST, and details names both components:

{
"path": "content.composition.root.children[3].id",
"message": "Id \"total\" is used twice in one tree: at root.children[1] and root.children[3]."
}

A header or footer variant is a tree of its own too, so it can reuse ids from the body and from other variants.

Ids and names change nothing in the document.

Tags say what a component is: a heading, a paragraph, a list. Screen readers read them from the PDF, and PDF/UA needs them. A tag does not change how the component looks, so set that with style as usual:

{
"type": "text",
"tag": "h1",
"text": "Invoice",
"style": { "fontSize": 32, "fontWeight": 700 }
}
Tag Means On
h1 to h6 A heading text, container
p A paragraph text, container
li A list item text, container
figcaption A figure’s caption text, container
ul, ol A list, unordered or numbered container, repeat
figure A figure, such as a chart with its caption container
section A section of the document container

A tagged component is laid out as a block, on its own line, unless its style or classes set display. The children of a flex container are blocks already, so tagging them moves nothing.

A repeat with "tag": "ul" or "ol" makes each item a list item, so the list needs no li of its own. When the array is empty, what empty shows is not a list. A list is tagged the same way without a tag, and draws its markers too.

Tags nest as in HTML, and PDF/UA holds them to it:

  • A heading cannot sit inside a paragraph or another heading, even with untagged containers between them; a figcaption outside a figure counts as a paragraph. A PDF/UA render fails. A heading in a figure’s figcaption is fine.
  • Inside a heading, no list, list item or table; inside a paragraph, no section. These render, but PDF/UA checkers such as veraPDF reject the file.
  • Inside a ul or ol container, every component is an li or another list. An li belongs in a list, and a figcaption in a figure; elsewhere screen readers hear a one-item list or a plain paragraph.

The visual editor lists these on the component, with a button that changes the tag. The MCP server’s tools refuse an edit that adds any of them, and name the tag to change. Saving a draft through the API does not check them.

Give every image alt, a literal or a binding, or mark it "decorative": true:

{
"type": "image",
"assetId": "logo",
"alt": { "path": ["company", "name"], "suffix": " logo" }
}

An empty literal alt, or alt together with decorative, fails the save with 400 BAD_REQUEST. When a bound alt comes out empty, the image has no alt text.

A PDF/UA render fails when the document has no heading or an image has no alt text, and names what to change. The preview’s conformance check lists the same problems.

text, html in rich text, a table column’s value, an image’s assetId and alt, a chart’s label and alt, a code’s value and alt, and a list’s items and text take a value:

  • A literal string (up to 100,000 characters), number or boolean: "Invoice", 42, true.
  • A binding to a path in the data: { "path": ["customer", "name"] }.
  • A sum or count over the rows of an array.
  • Mixed text joining literals, bindings, sums and counts.

Style values can be bound too; see styles from data.

Field Type Default Description
path string[] Required. 1 to 20 property names, each up to 128 characters.
scope string current current reads from the current repeat, table or list item, root from the whole data.
fallback string, number or boolean Shown when the path is missing or not a plain value.
map array Values to show in place of values in the data. See value maps.
format object How to format a number or date.
prefix string Text before the value, up to 1,000 characters.
suffix string Text after the value, up to 1,000 characters.

Array items use their index as a string, such as ["lines", "0", "name"]. The names __proto__, constructor and prototype are not allowed.

A data source (source in repeat, table and list, data in component) takes only path and scope.

Outside any repeat, table or list with a source, the current item is the whole data. Inside one, use "scope": "root" to reach data outside the item:

{
"id": "currency",
"header": "Currency",
"value": { "path": ["invoice", "currency"], "scope": "root" }
}

A binding must find a string, number or boolean. If the value is missing, null, an object or an array, the preview or render fails with 400 BAD_REQUEST naming the path. Give every optional value a fallback, even "":

{ "path": ["order", "note"], "fallback": "" }

The fallback is shown as written, without format, but with prefix and suffix.

parts joins 1 to 100 literals and bindings into one string of up to 1,000,000 characters:

{
"type": "text",
"text": {
"parts": ["Dear ", { "path": ["customer", "firstName"] }, ", your order has shipped."]
}
}

map shows another value in place of the one in the data, such as a label for a status code:

{
"path": ["order", "status"],
"map": [
{ "from": "paid", "to": "Paid" },
{ "from": "overdue", "to": "Payment overdue" }
],
"fallback": "Unknown"
}
  • map takes 1 to 100 entries. Each from and to is a string, number or boolean, and each from is listed once.
  • A value matches a from only when it is exactly equal, as with equals: 1 and "1" are different values.
  • A mapped value is shown as written, without format, but with prefix and suffix.
  • A value the map does not list is shown as it is, with format. A missing value uses the fallback, as without a map.

To pick a colour or another style by a value, see styles from data. To pick an image, map values to image IDs in assetId.

A binding’s format turns a number or date into text for a locale:

Field Type Default Description
type string Required. number, currency, percent or date.
locale string see below A locale such as de-CH, 2 to 64 characters.
currency string A three-letter ISO 4217 code such as EUR. Required for currency.
minimumFractionDigits integer 0 to 20. For number, currency and percent.
maximumFractionDigits integer 0 to 20. For number, currency and percent.
dateStyle string medium short, medium, long or full. For date.
timeZone string UTC An IANA time zone such as Europe/Berlin. For date.
Type Value Output (en-GB)
number A number 1,234.5
currency A number €1,234.50
percent A number, where 0.2 is 20% 20%
date An ISO date (2026-10-08), an ISO timestamp with a zone (2026-10-08T07:30:00Z), or milliseconds since 1970 8 Oct 2026

Numbers must be JSON numbers, not strings such as "12.50". A value of the wrong type fails with 400 BAD_REQUEST.

Without locale, the format uses the render’s language: the request’s locale for the Reports API (en-US when left out) and for a preview that sends one, otherwise the locale in page.json. The Renders API always uses page.json.

An aggregate adds up, counts or compares the rows of an array, and can stand anywhere a value can: in a text, a table column, rich text or mixed text parts, and in a condition.

{
"type": "text",
"text": {
"aggregate": "sum",
"source": { "path": ["lines"] },
"field": ["price"],
"format": { "type": "currency", "currency": "EUR" },
"prefix": "Total "
}
}
Field Type Description
aggregate string Required. sum, count, average, min or max.
source data source Required. The path of the array, as in a repeat.
field string[] The path of the number in each row, such as ["price"]. Without it, the rows are the numbers.
where condition Only the rows this condition holds for. It reads from each row.
fallback scalar A string, number or boolean shown for an average, min or max of no values.
format object How to format the result.
prefix string Text before the result, up to 1,000 characters.
suffix string Text after the result, up to 1,000 characters.
Aggregate Result With no values
sum The values added up. 0.1 and 0.2 make 0.3. 0
count The number of rows. It takes no field; filter with where. 0
average The sum divided by the number of values. fallback
min The smallest value. fallback
max The largest value. fallback
  • Rows whose field is missing or null are left out, so they do not lower an average.
  • Any other value that is not a JSON number, such as "12.50", fails the preview or render with 400 BAD_REQUEST naming the row, such as Sum over ["lines"] needs numbers, but ["lines","2","price"] is the string "12.50".
  • A source that is missing or null has no rows; any other value that is not an array fails with 400 BAD_REQUEST.
  • An average, min or max of no values without a fallback fails with 400 BAD_REQUEST.

where reads from each row, like the bindings inside a repeat. To total only some rows, such as the lines that carry tax:

{
"aggregate": "sum",
"source": { "path": ["lines"] },
"field": ["amount"],
"where": { "path": ["taxable"], "operator": "truthy" }
}

Inside a repeat or table, source reads from the current item, so each order can show the total of its own lines. To show a total of the whole data inside a row, use "scope": "root" in source. A total shown in every row reads its rows once.

One document tests its conditions and reads the rows of its sums and counts up to 10,000,000 times in all, each row once per condition in a where; more fails with 400 LIMIT_EXCEEDED.

visibleWhen shows a component only when a condition about the data holds:

{
"type": "text",
"text": "PAID",
"visibleWhen": {
"path": ["invoice", "status"],
"operator": "equals",
"value": "paid"
}
}
Operator Shows the component when the value is
truthy Present and not false, 0, "" or null.
falsy Missing, false, 0, "" or null.
exists Present and not null.
notExists Missing or null.
equals Exactly equal to value, same type and content.
notEquals Not exactly equal to value.
greaterThan A number greater than value.
greaterThanOrEquals A number greater than or equal to value.
lessThan A number less than value.
lessThanOrEquals A number less than or equal to value.

Conditions take path and scope like a binding. equals and notEquals need a value (a string, number or boolean); without one, the component is hidden. The four comparisons need a number value, or the save fails with 400 BAD_REQUEST, and they hold only for JSON numbers: a string such as "12", a missing value and null never compare. A missing path never fails a condition.

all holds when every condition in it holds, and any when at least one does. Groups take 1 to 100 conditions and can hold other groups. This shows a discount line for paid orders of members or of 500 or more:

{
"visibleWhen": {
"all": [
{ "path": ["order", "paid"], "operator": "truthy" },
{
"any": [
{ "path": ["customer", "member"], "operator": "truthy" },
{ "path": ["order", "total"], "operator": "greaterThanOrEquals", "value": 500 }
]
}
]
}
}

A group has either all or any, not both. One visibleWhen holds up to 100 conditions, counting the groups, nested up to 10 deep. A where in a sum or count counts as one level.

A condition can test an aggregate instead of a path: write the aggregate’s fields with an operator and value. This shows a note when an order has more than 20 lines:

{
"visibleWhen": {
"aggregate": "count",
"source": { "path": ["lines"] },
"operator": "greaterThan",
"value": 20
}
}

An average, min or max of no values counts as missing, so exists tells whether there is one. A value that is not a number fails as it does in a value.

style takes CSS properties in camelCase. Numbers are CSS pixels; anything else is a string:

{
"style": {
"display": "flex",
"gap": 12,
"padding": 8,
"borderWidth": 1,
"borderStyle": "solid",
"borderColor": "#e5e7eb"
}
}

A style value can come from the data instead of being written in the template. Write a binding with path, and optionally scope, fallback, map and unit, in place of the value:

{
"type": "text",
"text": { "path": ["status"] },
"style": {
"fontWeight": 600,
"color": { "path": ["statusColour"], "fallback": "#374151" }
}
}
  • Bindings read from the same data as the component’s values: inside a repeat, the current item; in a table’s cellStyle and column style, each row’s item; in a list’s itemStyle, each entry of its source. Header cells and headerStyle read from the table’s data.
  • A value that is missing, null, empty (""), an object or an array uses the fallback. Without a fallback, the property is left unset, as if the style did not name it.
  • map picks a style value for each value in the data, as value maps do. A value it does not list uses the fallback, or leaves the property unset without one.
  • unit gives a number from the data a unit: px, pt, pc, mm, cm, in, em, rem or %. A width of 40 with "unit": "mm" is 40mm. Without a unit, numbers are CSS pixels. Only properties that take a length take a unit.
  • Each value must suit its property, or the preview or render fails with 400 BAD_REQUEST naming the property and the path, such as Style "color" bound to ["statusColour"] must be a colour, such as #1f4fd1, rgb(31 79 209) or navy. A fallback or mapped value that does not suit its property fails when you save the draft.
  • Only the properties below can be bound. A binding on any other property, such as backgroundImage or transform, fails when you save the draft.
Property Takes
color, backgroundColor, borderColor, borderTopColor (and the other sides), outlineColor, textDecorationColor A colour: #1f4fd1, #1f4fd180, rgb(31 79 209), rgba(31, 79, 209, 0.5), hsl(220 75% 47%), a CSS colour name, transparent
width, height, minWidth, minHeight, flexBasis A length, or auto
maxWidth, maxHeight A length, or none
top, right, bottom, left, marginTop (and the other sides) A length, which may be negative, or auto
margin, inset One to four lengths or auto, such as "4mm auto"
padding, borderWidth, borderRadius One to four lengths, such as "4px 8px"
gap One or two lengths
paddingTop, borderTopWidth (and the other sides), borderTopLeftRadius (and the other corners), rowGap, columnGap, fontSize, outlineWidth A length
letterSpacing, wordSpacing, textIndent, outlineOffset A length, which may be negative
lineHeight A number such as 1.4, a length, or normal
fontWeight 1 to 1000, normal, bold, bolder or lighter
opacity 0 to 1
flexGrow, flexShrink A number of 0 or more
zIndex, order A whole number
fontFamily Family names separated by commas, such as "Inter, Arial" or "'Open Sans', sans-serif"
textAlign left, right, center, justify, start, end
verticalAlign baseline, top, middle, bottom, text-top, text-bottom, sub, super
fontStyle normal, italic, oblique
textTransform none, uppercase, lowercase, capitalize
textDecoration, textDecorationLine none, underline, overline, line-through
whiteSpace normal, nowrap, pre, pre-wrap, pre-line
display none, block, inline, inline-block, flex, inline-flex, grid
visibility visible, hidden
flexDirection row, row-reverse, column, column-reverse
flexWrap nowrap, wrap, wrap-reverse
justifyContent flex-start, flex-end, center, start, end, space-between, space-around, space-evenly
alignItems, alignSelf flex-start, flex-end, center, start, end, baseline, stretch
borderStyle, borderTopStyle (and the other sides) none, solid, dashed, dotted, double

A length is a number in CSS pixels, such as 12, or a string with a unit: px, pt, pc, mm, cm, in, em, rem, %, vw or vh, such as "4mm". Keywords and colour names ignore case.

To let a content editor pick a colour, bind it to a colour field with "scope": "root", so it is found inside tables and repeats too:

{
"backgroundColor": {
"path": ["$content", "accent"],
"scope": "root",
"fallback": "#1f4fd1"
}
}

To colour a status, map each status to its colour:

{
"color": {
"path": ["status"],
"map": [
{ "from": "paid", "to": "#15803d" },
{ "from": "overdue", "to": "#b91c1c" }
],
"fallback": "#374151"
}
}

To change more than a value, such as showing a different layout, show alternative components with visibleWhen.

For shared styles, set them once in the theme. Workspace stylesheets (stylesheets, or Template files in Studio) still work too: refer to their classes with className. See supported CSS.

The theme is the template’s style in one place: named colours, a spacing scale, fonts and text styles. Components use them by name, so changing a value in the theme restyles every component that uses it.

{
"root": {
"type": "container",
"textStyle": "body",
"style": { "padding": { "space": "lg" } },
"children": [
{
"type": "text",
"tag": "h1",
"textStyle": "heading",
"text": "Invoice"
},
{
"type": "container",
"style": { "height": 2, "backgroundColor": { "color": "accent" } }
}
]
},
"theme": {
"colors": { "ink": "#1f2937", "accent": "#1f4fd1" },
"spacing": { "sm": 4, "md": 8, "lg": "6mm" },
"fonts": { "body": "Inter, Arial" },
"textStyles": {
"body": {
"fontFamily": { "font": "body" },
"fontSize": 10,
"color": { "color": "ink" }
},
"heading": {
"fontSize": 22,
"fontWeight": 700,
"color": { "color": "accent" }
}
}
}
}
Field Type Description
colors object Up to 100 colours by name. Each is a colour or a binding.
spacing object Up to 50 spacing steps by name. Each is a length of 0 or more, such as 8 or "4mm", or a binding.
fonts object Up to 20 fonts by name. See fonts.
textStyles object Up to 50 text styles by name.

Names have up to 128 letters, digits, _ and -, and start with a letter or digit.

In style (and cellStyle, headerStyle, a column’s style and a totals row’s or cell’s style), write a theme value in place of a literal:

Write On
{ "color": "accent" } A colour property, such as color, backgroundColor or borderColor
{ "space": "md" } A length property, such as padding, marginTop, gap, width or fontSize, but not lineHeight
{ "font": "body" } fontFamily

The table of properties says which properties take a colour, a length or a font family. Saving a draft fails with 400 BAD_REQUEST when a name is not in the theme, or a value is used on a property that takes another kind, and details names the component:

{
"path": "content.composition.root.children[1].style.backgroundColor.color",
"message": "The theme has no colour \"brand\". Add it to theme.colors."
}

A text style is a set of style properties under a name, such as heading, body or small. Give a component textStyle to apply one; its own style overrides what the text style sets. A text style takes the same properties as style, including theme values and bindings.

Text properties pass to the components inside, as in CSS. To set the document’s font and colour, give the root a text style, as in the example above.

A font is either a list of family names, such as "Inter, Arial", or a family drawn from your uploaded font files:

{
"fonts": {
"heading": {
"family": "Brand Serif",
"files": [
{ "assetId": "6f1c2a4e-1d1b-4a8e-9a43-2b4f1f4e8c11" },
{ "assetId": "0b6e7d1c-5a2f-4e7b-8c1d-9f3a2e6b4d20", "weight": 700 }
],
"fallback": "Georgia, serif"
}
}
}
Field Type Description
family string Required. The name the files load under, up to 100 letters, digits, spaces, _ and -.
files array Required. 1 to 20 uploaded font files (TTF, OTF or WOFF2), described below.
fallback string Family names for characters the files do not have, such as "Georgia, serif".

Each file has:

Field Type Description
assetId string Required. The font’s ID: open the font file in Studio, where it is shown as Asset ID.
weight number The weight the file draws, 1 to 1000. Without it, the weight is read from the file.
style string normal or italic. Without it, the style is read from the file.

Add a file for each weight and style your text uses, such as a regular and a bold file. Text with { "font": "heading" } uses the family, then the fallback. Publishing copies the font files into the version, like images.

A theme colour or spacing step can be a binding instead of a literal, read from the whole data. Bind a colour to a content field so a content editor’s colour reaches every component that uses it:

{
"colors": {
"accent": { "path": ["$content", "accent"], "fallback": "#1f4fd1" }
}
}

A value that is missing, null or empty uses the fallback, or leaves the properties that use it unset. The binding also takes map and unit as in styles from data, such as a colour for each status. A value that is not a colour fails the preview or render with 400 BAD_REQUEST, as there.

A theme applies to component templates only. Saving one on a Handlebars template fails with 400 BAD_REQUEST.

In the visual editor, Brand in the page settings opens the template’s colours, spacing steps, fonts and text styles, and changes them. See template style.

The brand kit is your workspace’s logo, colours, spacing, fonts and text styles. New visual templates start from it, with the logo in the header. In Studio it opens from Brand in the visual editor’s page settings; see brand kit.

Through the API, GET /v1/brand-kit returns the kit and PUT /v1/brand-kit replaces the whole kit. Reading needs template:read, saving template:write. The kit takes the theme’s fields and a logo:

Terminal window
curl -X PUT https://app.typefold.dev/v1/brand-kit \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"logo": { "assetId": "6f1c2a4e-1d1b-4a8e-9a43-2b4f1f4e8c11", "alt": "Acme" },
"colors": { "accent": "#1f4fd1" },
"fonts": { "body": "Inter, Arial" }
}'

The logo is an uploaded image and font files are uploaded fonts in the workspace. Otherwise the request fails with 400 BAD_REQUEST, and details names the field. Templates that took the kit before keep their own theme.

POST /v1/brand-kit/website-drafts with a url reads that web page and returns a suggested kit and logo from its styles. It saves nothing: look it over, upload the logo, then PUT the kit.

header is drawn in the top margin of the pages, and footer in the bottom margin. Build each from components, with the same data as the body:

{
"root": { "type": "container", "children": [] },
"footer": {
"root": {
"type": "container",
"style": {
"display": "flex",
"gap": 4,
"justifyContent": "flex-end",
"padding": "0 15mm"
},
"children": [
{
"type": "text",
"text": { "path": ["invoice", "number"], "prefix": "Invoice " }
},
{ "type": "text", "text": "· Page" },
{ "type": "pageNumber" },
{ "type": "text", "text": "of" },
{ "type": "pageCount" }
]
},
"last": {
"type": "text",
"text": "Thank you for your order.",
"style": { "padding": "0 15mm" }
}
}
}

Every page except the last shows “Invoice A-1042 · Page 1 of 3”; the last page shows the thank-you line instead.

A header or footer has a component for every page, and variants for some pages:

Field Type Drawn on
root component Every page that no variant below covers.
first component or null The first page.
last component or null The last page.
odd component or null Pages 1, 3, 5 and so on.
even component or null Pages 2, 4, 6 and so on.

All fields are optional. first and last win over odd and even, and a one-page document uses first. null leaves those pages without the header or footer, such as "first": null for a cover page without one. A variant whose component is hidden by visibleWhen leaves its pages empty too.

  • The margin does not grow to fit: set topMm and bottomMm in the page settings large enough for the header and footer.
  • A header or footer spans the full page width. Pad it to line it up with the body, as with "padding": "0 15mm" above.
  • Header and footer components count toward the composition’s limits, and use the template’s stylesheets, theme, translations and reusable components like the body.

header and footer can also be Handlebars strings of up to 100,000 characters, as in HTML templates, with the same data. Elements with the pageNumber and totalPages classes show the page numbers. Only a component tree template can use components in its header and footer; an HTML template that sends them fails with 400 BAD_REQUEST.

format takes decimal, decimal-leading-zero, lower-roman, upper-roman, lower-alpha, lower-latin, upper-alpha, upper-latin, lower-greek, hiragana, katakana, trad-chinese-informal, cjk-ideographic, cjk-decimal, arabic-indic, bengali, cambodian, khmer, devanagari, gujarati, gurmukhi, kannada, lao, malayalam, mongolian, myanmar, oriya, persian, urdu, tamil, telugu, thai and tibetan.

Translation files work as in Handlebars templates: the file for the render’s language is added to the data as localization, unless the data already has one. Bind its labels like any value:

{ "type": "text", "text": { "path": ["localization", "invoiceTitle"] } }

A table column’s header takes the same binding. Inside a repeat or a table, add "scope": "root" so the key is read from the document’s data rather than the item’s: { "path": ["localization", "amount"], "scope": "root" }.

When a design needs more than the components offer, convert the template into an HTML template that renders the same pages and keep editing it as HTML. In Studio, use More actions → Convert to HTML in the visual editor; see switch to code.

Through the API, the conversion returns a new draft and leaves the template as it was:

Terminal window
curl -X POST https://app.typefold.dev/v1/templates/$TEMPLATE_ID/html-conversion \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{}'

It converts the saved draft, or the one you send as draft. The response holds the HTML template’s content and a list of warnings, each with the path in the tree it is about and a message. Save the content as a new template, or over this one’s draft, with PUT /v1/templates/{id}/draft:

Terminal window
curl https://app.typefold.dev/v1/templates \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{ "name": "Order confirmation (HTML)", "content": { ... } }'
In the tree In the HTML template
Components and their styles Elements with the same tags and inline styles, after a short stylesheet that matches the tree’s layout.
Bindings, format and value maps Handlebars expressions with the built-in format helper.
Styles from data The built-in styleValue helper.
richText The built-in richText helper.
Sums, counts and conditions Helpers in helpers.js, written for this template.
Reusable components Inline partials.
Images {#asset} tags naming the image’s workspace file.
qrCode and barcode The qrCode and barcode helpers.
chart The built-in chart helper, which draws the same image.
formField, certificateSignature The same fields and signature place, through a helper in helpers.js.
Header and footer root header.html and footer.html.
columns, list, divider, spacer Flex rows, ul and ol lists, and boxes with the same styles.
Theme colours and spacing steps Their values, written where they are used; one from data through styleValue.
Text styles Their properties, in the inline style of each component that uses them.
Theme fonts Family names, and an @font-face rule for each uploaded font file, named by its workspace file.

An HTML template has no theme, so a theme value changed later must be changed where it is used. Page settings, translations and other draft fields stay as they are. Leave the generated helpers.js functions in place while the template uses them; they are ordinary helpers.

The conversion still succeeds, but tells you about:

  • Header and footer variants. HTML draws the same header and footer on every page, so the first, even, odd and last variants are left out.
  • Tags HTML cannot nest, such as a list inside a p. The block becomes a div: it looks the same, but screen readers read it as a group.
  • Barcode options the HTML helper takes for itself (class, style, alt, type), or whose names are not plain words, are left out.
  • Scripts. A component tree template runs no scripts. Scripts in the draft are left out, and the workspace’s scripts that run before every render, or before renders in the template’s folder, will run before the HTML template.
  • A missing value with no fallback prints nothing in HTML, where the tree fails the render. Other data errors, such as text where a sum needs numbers, fail both.
  • A style from data that is true or false and has no value map uses the fallback in HTML, where the tree fails. A theme colour or spacing step from data is checked as a value of the property that uses it, which can take more, such as auto for width.
  • In richText, text written outside paragraphs next to lists can be spaced slightly differently.
Status and code When
400 BAD_REQUEST The template is not a component tree, or the converted template is over the size limits.
400 BAD_REQUEST A formField or certificateSignature is in a header or footer.
400 ASSET_INVALID An image or font file is not a file in the workspace, so HTML cannot name it. Add it to the workspace.
403 FORBIDDEN The API key lacks template:read.
404 NOT_FOUND No such template in the workspace.

Field limits are in the tables above. Limits on the whole composition, such as the number of components and nesting depth, are in limits. Limits checked when you save the draft fail with 400 BAD_REQUEST; limits checked when a preview or render fills in the data fail with 400 LIMIT_EXCEEDED.

A draft that does not match the shapes on this page also fails with 400 BAD_REQUEST. Its details name each field at fault, such as content.composition.root.children[1].text, with what was wrong there.

To render a tree you build in code without keeping a template, send a node document to POST /v1/renders. It has its own shape, with no bindings; see render documents.