Skip to main content

Custom Variables

[API Docs] [SDK]

Custom Variables allow you to create reusable template logic stored at the organization level. They encapsulate Handlebars expressions, order table configurations, journey links, and text snippets into named variables that can be referenced across email and document templates.

Custom variables are particularly useful for complex HTML markup that needs to render consistently in both emails and documents. For example, an order confirmation table with line items, pricing, and tax breakdowns can be defined once as a custom variable and reused across order confirmation emails and PDF contracts.

Variable Builder​

Access the Variable Builder UI at Configuration > Templates > Variable Builder (direct link).

Variable Types​

TypeDescription
customFree text combined with Handlebars helpers. Use for reusable logic and computed values.
order_tableRenders an HTML order table with configurable columns, styling, headers, and footers. See Order Table Variable.
journey_linkGenerates a signed journey link using generateJourneyLink.
snippetReusable text snippets for common content blocks.

Usage in Templates​

Reference a custom variable using its key:

{{custom_variable_key}}

For order table variables, use the ~~ prefix:

{{~~my_order_table}}

API Operations​

OperationMethodPath
List allGET/v1/custom-variables
CreatePOST/v1/custom-variables
Get by IDGET/v1/custom-variables/{id}
UpdatePUT/v1/custom-variables/{id}
DeleteDELETE/v1/custom-variables/{id}
SearchPOST/v1/custom-variables:search

Data Model​

FieldTypeDescription
idstringUnique identifier
typestringOne of custom, order_table, journey_link, snippet
namestringDisplay name
keystring (required)Key used in Handlebars syntax {{key}}
templatestring (required)Handlebars template content
configobjectType-specific configuration (e.g., column layout for order tables)
_tagsstring[]Tags for categorization and filtering
helper_paramsstring[]Parameter names for helper function logic
helper_logicstringJavaScript logic for helper function
created_atstringCreation timestamp
updated_atstringLast update timestamp

Relation Filtering (Look-Ahead)​

When referencing related entities (e.g., orders within an opportunity), you can filter which relation to use with bracket syntax.

Tag-Based Filtering​

Filter by tag value from _tags:

{{opportunity.items[approved].line_items}}
{{~~order_table_items[approved]}}

Attribute-Based Filtering​

Filter by a specific attribute value using =:

{{opportunity.items[status=approved].line_items}}
{{~~order_table_items[status=approved]}}

The syntax is determined automatically:

  • When = is present: filters by attribute_name = attribute_value
  • When = is absent: filters by tag value in _tags

You can combine attribute filtering with order table variable properties:

{{~~order_table_items[status=approved] mt=5.5 mb=3.5}}

Code Example​

Create a custom variable:

curl -X POST https://template-variables-api.sls.epilot.io/v1/custom-variables \
-H "Authorization: Bearer $EPILOT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Greeting",
"key": "custom_greeting",
"type": "custom",
"template": "Hello {{contact.first_name}} {{contact.last_name}}!",
"_tags": ["greeting"]
}'

Search for custom variables by type:

curl -X POST https://template-variables-api.sls.epilot.io/v1/custom-variables:search \
-H "Authorization: Bearer $EPILOT_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "order_table",
"size": 10
}'