Template Variables
The Template Variables API handles variable discovery and substitution for email and document templates using Handlebars.
Template Variables APIโ
The API discovers available variables and executes substitution. When a template renders, the API fetches entity data and other context to resolve each variable.
Computed metadata fieldsโ
Some entity fields store identifiers (slugs or UUIDs). The API expands these into human-readable values using the :<field> suffix.
Tagsโ
Access resolved tag names from the _tags slug array:
Purposeโ
Access resolved purpose names from the _purpose UUID array:
If a purpose ID cannot be resolved, the raw ID is returned.
Variable Pickerโ
The variable picker UI lets users search and explore available variables.
Variable Builderโ
Create custom variables in Configuration > Templates > Variable Builder (direct link).

Custom Variablesโ

Custom variables combine free text with any Handlebars helper. Reference them in templates with:
tip
You can use Handlebars helpers directly in templates. Custom variables are useful for encapsulating reusable logic.
Order Table Variableโ

Order tables display line items from an Order. They support Custom Variables and Handlebars Helpers.

Customize column order, styling, visibility, headers, and footers.

Reference an order table variable in templates with:
Custom Handlebars Helpersโ
Standard Handlebars Helpersโ
All helpers from the handlebars-helpers library are available: math, number, date, comparison, array, string, object, url, and more.
formatAddressโ
Formats an address object into a single-line string. Returns empty string for invalid input.
calculateColspanโ
Calculates the colspan for table cells based on the table configuration. Used with Order Table Variables.
calculatePeriodColspanโ
Calculates the colspan for period-related table columns. Used with Order Table Variables.
calculateSummaryColspanโ
Calculates the colspan for summary sections based on enabled columns. Used with Order Table Variables.
isColumnEnabledโ
Returns true if the specified column ID is enabled in the table configuration. Used with Order Table Variables.
shouldDisplayDetailsโ
Returns true if the column's showDetails property is set. Used with Order Table Variables.
isSummaryVisibleโ
Returns true if at least one non-draggable column is enabled. Used with Order Table Variables.
isExternalFeesMetadataVisibleโ
Returns true if external_fees_metadata is enabled in the table footer. Used with Order Table Variables.
gtโ
Compares two numbers and returns true if the first is greater than the second.
ltโ
Compares two numbers and returns true if the first is less than the second.
eqโ
Compares two numbers and returns true if they are equal.
blockHelperMissingโ
Returns an empty string when a block helper is missing.
helperMissingโ
Returns an empty string when a helper is not found.
makeStyleโ
Converts a table configuration object into a CSS style string. Used with Order Table Variables.
<schema>.<property>โ
Dynamically registered from schema attributes (e.g., main.email, contact.name). Retrieves a property value from context data, prioritizing items tagged as "primary" or the first array element. Address properties are automatically formatted as full addresses.
emailโ
Retrieves the email from context, prioritizing email then billing_email. Returns the first element if the value is an array.
billing_emailโ
Retrieves the billing email from context, prioritizing billing_email then email. Returns the first element if the value is an array.
phoneโ
Retrieves the phone number from context, prioritizing phone then billing_phone. Returns the first element if the value is an array.
billing_phoneโ
Retrieves the billing phone from context, prioritizing billing_phone then phone. Returns the first element if the value is an array.
addressโ
Formats an address from context, searching for addresses tagged billing or primary. Falls back to the first address.
billing_addressโ
Formats an address from context, searching for addresses tagged billing, shipping, or primary. Falls back to the first address.
shipping_addressโ
Formats an address from context, searching for addresses tagged shipping, billing, or primary. Falls back to the first address.
delivery_addressโ
Formats an address from context, searching for addresses tagged delivery or primary. Falls back to the first delivery address.
additional_addressโ
Formats an address from context, searching for addresses tagged primary.
withTagโ
Retrieves a value from an array by tag (defaults to primary) and optional attribute.
ynโ
Converts a boolean-like value to a localized "Yes" or "No" string. Accepts optional custom success/failure values.
xifโ
Returns "x" if the input is truthy, otherwise an empty string.
customOrderTableVariableโ
Renders an Order Table Variable.
formatDateTimeโ
Formats a date/time string with a specified pattern. Defaults to short date-time format.
formatDateโ
Formats a date string with a specified pattern. Defaults to date-only format.
dateMathโ
Performs date arithmetic (add/subtract days, months, etc.). Accepts inputDate, expression, inputFormat, and format parameters.
padStartโ
Pads a string to a target length with a specified character (defaults to space).
generateJourneyLinkโ
Generates a signed journey link. Pass parameters as space-separated key-value pairs.
Required: journey_id
Optional:
custom_url-- custom domain for the URLexpires_in-- token expiration (ms format)nonce-- add a nonce to the payload (boolean)
Automatically includes initial_submission_id from context when available.
asCurrencyโ
Formats a number as a currency string using @epilot/pricing. Accepts currency (default: EUR), locale (default: de), and displayZeroAmount (default: false).
Excel-like Formulasโ
Use the calc helper for Excel-like formulas in templates.
Available formulasโ
Arithmetic operatorsโ
+- Addition-- Subtraction*- Multiplication/- Division^- Exponentiation%- Modulus (remainder of division)()- Parentheses for grouping expressions-number- Negation (unary minus)
Formula functionsโ
ABS(number)- Returns the absolute value of a number.AND(condition1, condition2, ...)- Returnstrueif all conditions are truthy.AVERAGE(number1, number2, ...)- Returns the average of a set of numbers.CEIL(number)- Rounds a number up to the nearest integer.FLOOR(number)- Rounds a number down to the nearest integer.IF(condition, value_if_true, value_if_false)- Returns one value if condition is truthy and another value if it's falsey.MAX(number1, number2, ...)- Returns the largest number in a set of numbers.MIN(number1, number2, ...)- Returns the smallest number in a set of numbers.NOT(condition)- Reverses the value of its argument. Returnstrueif its argument is truthy andfalseif its argument is falsey.OR(condition1, condition2, ...)- Returnstrueif any condition is truthy.ROUND(number, [places])- Rounds a number to a specified number of decimal places. If places is omitted, it defaults to 0.SUM(number1, number2, ...)- Returns the sum of a set of numbers.RAND()- Returns a random number between 0 (inclusive) and 1 (exclusive).
Date functionsโ
All date functions work with ISO 8601 date strings (e.g., "2025-09-26" or "2025-09-26T12:00:00Z") and use UTC by default with optional timezone support.
Current timeโ
NOW([timezone])- Returns the current date and time in ISO format (e.g., "2025-09-26T12:00:00.000Z")TODAY([timezone])- Returns the current date in ISO format (e.g., "2025-09-26")
Date arithmeticโ
DATEADD(date, value, unit, [timezone])- Adds/subtracts time from a date- Units: "years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds"
DATEDIFF(start_date, end_date, unit, [timezone])- Calculates difference between dates- Returns floor of the difference (e.g., 1.9 months = 1)
Date componentsโ
YEAR(date, [timezone])- Extract year (e.g., 2025)MONTH(date, [timezone])- Extract month (1-12)DAY(date, [timezone])- Extract day of month (1-31)HOUR(date, [timezone])- Extract hour (0-23)MINUTE(date, [timezone])- Extract minute (0-59)SECOND(date, [timezone])- Extract second (0-59)WEEKDAY(date, [type], [timezone])- Get day of weektype=1: Sunday=1, Saturday=7 (Excel default)type=2or omitted: Monday=1, Sunday=7 (ISO)type=3: Monday=0, Sunday=6
Week calculationsโ
WEEKNUM(date, [type], [timezone])- Get ISO week number of the year