Docs Guides

Using Variables

Learn how to add dynamic content to your email templates with variables.

Overview

Variables let you personalize emails with dynamic content. Instead of hardcoding names, dates, or links, use variables that get replaced with real values at send time.

Variable Syntax

Variables use double curly braces with an optional default:

{{variableName|defaultValue}}

Examples

Hello {{firstName|there}}!

Your order #{{orderNumber}} has shipped.

Track your package: {{trackingUrl}}

With and Without Defaults

With Default

{{firstName|Friend}}

If firstName isn’t provided, shows “Friend”.

Without Default

{{firstName}}

If firstName isn’t provided, shows empty string.

Empty Default

{{middleName|}}

Explicitly shows nothing if not provided.

Where to Use Variables

Variables work in:

  • Body text - Hello {{name}}!
  • Subject lines - Your order {{orderNumber}} is ready
  • Button text - View {{itemName}}
  • Links - https://example.com/track/{{trackingId}}
  • Alt text - Photo of {{productName}}

Variables Panel

The editor automatically extracts variables from your template:

  1. As you type {{variableName}}, it appears in the variables panel
  2. Set default values in the panel
  3. Preview with sample data

Providing Values via API

When calling the API, pass variables in the request:

{
  "templateId": "tmpl_abc123",
  "variables": {
    "firstName": "Alice",
    "orderNumber": "12345",
    "trackingUrl": "https://example.com/track/abc"
  },
  "_to": "alice@example.com"
}

Reserved Fields

Fields starting with _ are reserved for email delivery:

FieldPurpose
_toRecipient email address
_subjectOverride subject line
_replyToReply-to address
_ccCC recipients
_bccBCC recipients

These aren’t template variables—they configure email delivery.

Variable Naming

Good Names

  • firstName
  • orderNumber
  • companyName
  • resetLink

Avoid

  • first name (no spaces)
  • 1stName (don’t start with numbers)
  • _reserved (underscore prefix is reserved)

Nested Content

For conditional content, use defaults strategically:

{{couponSection|}}

Then provide HTML for couponSection when you want it shown, or omit it to show nothing.

Common Patterns

Personalized Greeting

Hi {{firstName|there}},

Order Confirmation

Order #{{orderNumber}}
Shipping to: {{shippingAddress}}
Estimated delivery: {{deliveryDate|3-5 business days}}

Password Reset

Click here to reset your password:
{{resetLink}}

This link expires in {{expiry|24 hours}}.

Welcome Email

Welcome to {{companyName}}, {{firstName}}!

Here's what you can do next:
{{gettingStartedSteps}}

Testing Variables

  1. Add variables to your template
  2. Open the preview
  3. Enter test values in the variables panel
  4. See the rendered result

Debugging

Variable not replaced?

  • Check spelling matches exactly (case-sensitive)
  • Ensure curly braces are correct: {{ not {
  • Verify you’re passing the variable in the API call

Seeing raw {{variable}}?

  • The variable has no default and wasn’t provided
  • Add a default: {{variable|default}}