Skip to content

Templates

Templates define the layout and content of your documents. They can be created in the dashboard’s visual editor or defined as JSON and sent inline with render requests.

Every template follows this structure:

{
"formatVersion": 1,
"meta": {
"name": "Shipping Label",
"description": "4x6 shipping label with barcode",
"tags": ["shipping", "labels"]
},
"dimensions": {
"width": "4in",
"height": "6in",
"safeMargin": "3mm"
},
"schema": { ... },
"sample": { ... },
"elements": [ ... ]
}
FieldTypeRequiredDescription
formatVersionnumberYesMust be 1.
metaobjectYesTemplate metadata.
meta.namestringYesTemplate name.
meta.descriptionstringNoHuman-readable description.
meta.tagsstring[]NoOrganizational tags.
dimensionsobjectYesDocument dimensions.
dimensions.widthstringYesWidth with unit (e.g., "4in", "100mm").
dimensions.heightstringYesHeight with unit.
dimensions.safeMarginstringNoSafe margin inset from edges.
schemaobjectNoJSON Schema for validating data at render time.
sampleobjectNoSample data used for dashboard thumbnails.
elementsarrayYesArray of design elements.

Dimensions and positions accept values with these units:

UnitExampleDescription
in"4in"Inches
mm"100mm"Millimeters
cm"10cm"Centimeters
pt"288pt"Points (1/72 inch)
px"384px"Pixels (at 96 DPI)

Elements are the building blocks of a template. Each element has a type, position, size, and type-specific properties.

FieldTypeRequiredDescription
idstringYesUnique element identifier.
typestringYesElement type (see below).
positionobjectYesPositioning configuration.
widthstringYesElement width with unit.
heightstringYesElement height with unit.
rotationnumberNoRotation in degrees.
visiblestringNoExpression — element is hidden when it evaluates to falsy.
TypeDescription
textText content with font styling. Supports expressions for dynamic content.
barcode1D barcode (Code 128, Code 39, etc.).
qrcodeQR code.
datamatrixData Matrix 2D barcode.
imageStatic or dynamic image from a URL.
lineHorizontal or vertical line.
rectRectangle with optional fill and border.

Elements support two positioning modes:

Absolute — positioned relative to the document origin:

{
"position": {
"mode": "absolute",
"x": "10mm",
"y": "20mm"
}
}

Relative — positioned relative to another element:

{
"position": {
"mode": "relative",
"anchor": "other-element-id",
"offset": { "x": "0mm", "y": "5mm" }
}
}

Elements can use expressions to dynamically render content from the data object passed at render time.

Text and barcode elements use the content field:

{
"type": "text",
"content": {
"expression": "data.customer.name"
}
}

Expressions are JavaScript expressions evaluated at render time. The data object is available in scope.

{
"content": {
"expression": "data.quantity + ' x ' + data.productName"
}
}

For static text, use the value field instead of expression:

{
"content": {
"value": "SHIP TO:"
}
}

Any element can be conditionally shown or hidden using the visible field:

{
"visible": "data.priority === 'rush'"
}

Templates created in the dashboard are stored and can be referenced by ID in render requests using templateId. Published templates are available to API keys; draft templates are only accessible via the dashboard.

StatusAPI Key AccessDashboard Access
DraftNoYes
PublishedYesYes