Skip to main content

Template Variables

[API Docs] [SDK]

The Template Variables API handles variable discovery and substitution for email and document templates using Handlebars.

Overviewโ€‹

Template variables allow you to insert dynamic content into your templates. When a template renders, the API fetches entity data and resolves each variable to its actual value.

Hello {{contact.first_name}},

Your order {{order._title}} has been confirmed.
Total: {{asCurrency order.total "EUR"}}

For a complete list of available variables and helpers, see the Variable Reference.

Quick Startโ€‹

Basic Entity Variablesโ€‹

Access entity attributes using the entity slug as a prefix:

{{contact.first_name}}
{{contact.last_name}}
{{order._title}}
{{opportunity.billing_address}}

System Variablesโ€‹

{{system.date}}    <!-- Current date -->
{{system.time}} <!-- Current time -->

Environment Variablesโ€‹

Reference organization-level configuration. See Environments & Secrets.

{{env.portal.domain}}
{{env.erp_api.base_url}}

Variable Pickerโ€‹

The variable picker UI in the template editor lets users search and explore available variables. Use it to discover entity attributes, helpers, and custom variables.

Variable Builder UI

Custom Variablesโ€‹

Create reusable template logic in Configuration > Templates > Variable Builder (direct link).

Custom Variables

Custom variables combine free text with Handlebars helpers. Reference them in templates with:

{{custom_variable_name}}

For details, see Custom Variables.

Order Table Variablesโ€‹

Order table variables display line items from an Order with configurable columns, styling, and footers.

Order Table Variable

Reference order tables with the ~~ prefix:

{{~~custom_table_key}}

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:

{{opportunity._tags:name}}
{{_tags:name}}

Purposeโ€‹

Access resolved purpose names from the _purpose UUID array:

{{opportunity._purpose:name}}
{{_purpose:name}}

Handlebars Helpersโ€‹

epilot provides a rich set of Handlebars helpers for formatting, calculations, and logic. Here are the most commonly used:

Date Formattingโ€‹

{{formatDate "2025-05-13" "dd.MM.yyyy"}}
{{formatDateTime order.created_at}}
{{dateMath order.date "+14d"}}

Currency Formattingโ€‹

{{asCurrency 1000 "EUR"}}
{{asCurrency order.total "EUR" "de"}}

Address Formattingโ€‹

{{formatAddress 'billing_address.0'}}
{{billing_address}}
{{shipping_address}}

Boolean Formattingโ€‹

{{yn is_active}}              <!-- Yes/No -->
{{yn is_active "On" "Off"}} <!-- Custom labels -->

Tag-Based Filteringโ€‹

{{withTag contacts tag="billing" attribute="email"}}

For the complete helper reference, see Variable Reference - Handlebars Helpers.

Excel-like Formulasโ€‹

Use the calc helper for Excel-like formulas:

{{calc "ROUND(price * quantity, 2)"}}
{{calc "IF(qty > 10, 10, qty)"}}
{{calc "SUM(price1, price2, price3)"}}
{{calc "DATEADD(order.date, 14, \"days\")"}}

Available Functionsโ€‹

CategoryFunctions
MathABS, CEIL, FLOOR, ROUND, SUM, AVERAGE, MIN, MAX, RAND
LogicIF, AND, OR, NOT
DateNOW, TODAY, DATEADD, DATEDIFF, YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, WEEKDAY, WEEKNUM

For detailed formula documentation, see Variable Reference - Excel-like Formulas.

Where Variables Are Supportedโ€‹

Template variables are supported across epilot:

FeatureDescription
Email templatesSubject lines and body content
Document templatesWord documents (.docx) with variable placeholders
WebhooksURL, headers, and payload content
Automation actionsAction parameters and payloads
Entity mappingTransformation rules
Customer PortalDynamic content and links
ERP integrationsConfiguration and data transformation