Skip to content

Search documentation

Search pages and sections

Sending

Template syntax

Personalise subjects and bodies with variables, conditionals and loops, and send stored templates by ID.

Templates use a small, Handlebars-style syntax. It works in the subject, HTML and plain-text parts of stored templates, and in emails you send inline with variables.

Variables

Wrap a variable name in double braces. Use dots to reach nested values. Values are HTML-escaped by default, so user input can’t inject markup.

<p>Hi {{first_name}},</p>
<p>Your order {{order.number}} ships to {{order.address.city}}.</p>
variables
{ "first_name": "Ada", "order": { "number": "#4821", "address": { "city": "London" } } }

Missing variables render as an empty string.

Fallback values

Use {{#if}} with {{else}} to provide a fallback:

Hi {{#if first_name}}{{first_name}}{{else}}there{{/if}},

Raw HTML

Triple braces output a value without escaping. Only use them for HTML you generated and trust.

{{{receipt_table_html}}}
Never pass user-supplied content to triple braces — it can break your layout or inject links.

Conditionals

{{#if value}} renders its block when the value is truthy (not empty, false, 0, null or an empty list). {{#unless}} is the inverse.

{{#if trial_ends_at}}
  <p>Your trial ends on {{trial_ends_at}}.</p>
{{else}}
  <p>Thanks for being a customer!</p>
{{/if}}

{{#unless email_verified}}
  <a href="{{verify_url}}">Verify your email</a>
{{/unless}}

Loops

{{#each list}} repeats its block for every item. Inside the block, fields of the current item are available directly; {{this}} is the item itself and {{@index}} its zero-based position.

<table>
  {{#each items}}
    <tr>
      <td>{{@index}}. {{name}}</td>
      <td>{{quantity}} × {{price}}</td>
    </tr>
  {{else}}
    <tr><td>Your cart is empty.</td></tr>
  {{/each}}
</table>

Sending a template

Create templates in the dashboard (Templates) or with the Templates API, then send by ID. Anything you pass explicitly — such as subject — overrides the template.

curl https://hulakimail.com/api/v1/emails \
  -H "Authorization: Bearer $HULAKIMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <[email protected]>",
    "to": ["[email protected]"],
    "template_id": "tpl_01JD3R2K6Q8W4M1T7Z9X5B3N0C",
    "variables": {
      "first_name": "Ada",
      "items": [{ "name": "Himalayan tea sampler", "quantity": 1, "price": "$49.00" }]
    }
  }'

Built-in campaign variables

Campaign emails can use contact fields plus a few built-ins:

VariableValue
{{email}}The contact’s email address
{{first_name}}, {{last_name}}Standard contact fields
{{fields.<key>}}Any custom field, e.g. {{fields.plan}}
{{unsubscribe_url}}One-click unsubscribe link (added automatically if missing)
{{preferences_url}}Link to the subscriber preference center

Tips

  • Always provide a plain-text part — or let Hulaki generate one from the HTML.
  • Use the template preview with sample data before sending to real recipients.
  • Keep logic simple; compute values like prices and dates in your app and pass them as strings.

Something unclear or missing? Tell us.