Skip to main content

Template Variables

Custom Template variables provide your team flexibility when sending emails. Define custom variables for your Template with optional fallback values which will be replaced with the actual values when sending the email. Each Template may contain up to 50 variables. You can define and then reference these variables in your Template to send emails with personalized content.

Create custom variables

To add a custom variable to your Template, select Variable in the commands palette or type {{ in the Dashboard editor. Define the name, type, and fallback_value (optional).

You can also define custom variables when you create a Template via the API. The payload can optionally include variables to be used in the Template.

The following variable names are reserved and cannot be used: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, contact,this.
Each variable is an object with the following properties:
  • key: The key of the variable, commonly uppercase (e.g., PRODUCT_NAME).
  • type: The type of the variable ('string' or 'number').
  • fallback_value: The fallback value of the variable. If no fallback value is provided, you must provide a value for the variable when sending an email using the Template.
See the API reference for more details.

Fallback values

When you define a variable, you can optionally define a fallback value. This value will be used when sending the email if you fail to provide a value in your call. In the editor, if you fail to provide a fallback value, a warning sign will show for the variable. To edit a variable’s fallback value, click on the variable chip in your Template and use the Inspector sidebar on the right to update the fallback value. You can also include fallback values when creating a Template via the API.

Send Test Emails

You can send test emails to your inbox to preview your Template before sending it to your audience. Provide variable values to test the rendered Template in your inbox.

Send a Template with Variables

When sending a transactional email, you can reference your Template and include your variables in the call. The Template variables will be replaced with the actual values.
  • id: id of the published Template
  • variables: array of variable objects (if applicable)
Both the /emails and /emails/batch endpoints support Templates.
If a template is provided, you cannot send html, text, or react in the payload, otherwise the API will return a validation error.When sending a Template, the payload for from, subject, and reply_to take precedence over the Template’s defaults for these fields. If the Template does not provide a default value for these fields, you must provide them in the payload.
Learn more about sending emails or sending batch emails with Templates via the API.

Validation errors

When sending an email using a Template, the Template variables will be replaced with the actual values. If a variable is not provided, the fallback value will be used. If no fallback value is provided, the email will not be sent and a validation error will be returned.

API Reference

For complete API documentation, see the Templates API reference and the template parameter of the Sending API.