API

Template variables

Put each person's own values, lists, and conditions into a template, and preview before you send.

Variables put a different value into each email. One abandoned cart template can show each person their own name, items, and checkout link.

Writing variables

Put a name in double curly braces anywhere in the subject, preview text, HTML body, or plain-text body.

  • {{first_name}} shows the value, or nothing when it is missing.
  • {{first_name|there}} shows the value, or the word there when it is missing. The older form {{first_name | default: "there"}} still works.
  • {{#each cart_items}} ... {{/each}} repeats the middle part once for each item in a list. Inside it, {{name}} reads the name field of the current item.
  • {{#if coupon}} ... {{/if}} shows the middle part only when coupon has a value or a saved default.
  • {{#if plan == "pro"}} ... {{/if}} shows the middle part only when plan is that text, ignoring upper and lower case. Use one block for each value you want to word differently.

Names start with a lowercase letter and use lowercase letters, numbers, and underscores, up to 64 characters. There is no other logic. Anything else in braces is left as written.

Contact fields

These fill themselves from the person being emailed: email, first_name, last_name, full_name, phone, whatsapp, country, and tags (separated by commas). A value in variables with the same name replaces the contact field for that one email.

{{custom.key}} shows the person's value for one of your contact fields, such as {{custom.last_order_date}} or {{custom.order_count|0}}. Dates show as 2026-10-21, and yes or no fields as true or false. {{#if custom.key}} works too, and false counts as empty. These are not template variables: they need no settings, do not count towards the plan's variable limit, and a contact with no value gets the fallback or a blank without a warning. A key that is not one of your fields warns unknown variable: custom.key. See Contact fields API.

Types

Saving a template finds every variable in it. Each one has a type, an optional default, and a required switch. Set them in Email Templates under Variables, or with PUT /api/v1/templates/{id}/variables.

TypeSend it as
textA string or a number
numberA number, or a string such as "3"
dateA date string, such as 2026-10-21
htmlAn HTML string. It is inserted as written.
listAn array of objects, shown with {{#each}}

Values in the HTML body are escaped, so <b>x</b> shows as text. Only html variables are inserted as written, so use html only for HTML you trust. The subject, preview text, and plain-text body are never escaped.

Missing values

  • A missing value uses the fallback written in the template first, then the saved default.
  • A required variable with no value and no default stops the send with HTTP 422. The response names the variable, and nothing is sent or saved.
  • A value of the wrong type also returns HTTP 422 with the variable name.
  • Campaigns fill variables from each contact. A variable with no matching contact field uses its default. A campaign keeps sending when a value is missing: the email uses the default, or a blank.
json
{
  "error": "checkout_url is required",
  "code": "invalid_variables",
  "variable": "checkout_url",
  "errors": [{ "variable": "checkout_url", "message": "checkout_url is required" }]
}

Warnings

A variable with no value and no default renders as a blank, and the send records a warning such as unknown variable: coupon. A contact field that is empty, such as a person with no first name, is a value and does not warn.

  • Send one email returns the warnings in warnings.
  • GET /api/v1/sends/{id} returns them in render_warnings.
  • The campaign delivery log and Analytics show them next to each address.

Preview before you send

POST/api/v1/templates/{id}/preview

Scope

templates:read

Fields

emailfirst_namelast_namevariables

Returns

subject, preheader, html, text, warnings

Preview runs the same steps as a real send, including branding, the VeloSend badge when your project shows it, and the unsubscribe link. It sends nothing and saves nothing. A required variable that is missing returns the same 422 as a send. Links in a preview use the word preview where a real send has its own tracking token.

Variable settings

PUT/api/v1/templates/{id}/variables

Scope

templates:write

Fields

variables (required)

Returns

name, type, default_value, required for every variable in the template

json
{
  "variables": [
    { "name": "checkout_url", "type": "text", "required": true },
    { "name": "cart_items", "type": "list" },
    { "name": "first_name", "default_value": "there" }
  ]
}

Only names already used in the template can be changed here. To add a variable, add it to the content and save the template. Variables you leave out keep their settings, and each change is kept in the audit log. A list variable cannot have a default.

Plan limit

Each plan sets how many variables one template can use. Saving a template with more returns the standard 402 limit error, and the template is not saved.

Example: abandoned cart

Template HTML

html
<p>Hi {{first_name|there}}, you left these in your cart:</p>
<table>
  {{#each cart_items}}
  <tr><td>{{name}}</td><td>{{qty}}</td><td>{{price}}</td></tr>
  {{/each}}
</table>
{{#if coupon}}<p>Use {{coupon}} for 10% off.</p>{{/if}}
<a href="{{checkout_url}}">Finish checkout</a>

Send body for POST /api/v1/templates/{id}/send:

json
{
  "email": "priya@example.com",
  "first_name": "Priya",
  "variables": {
    "cart_items": [{ "name": "Kids Gummies", "qty": 2, "price": "₹499" }],
    "checkout_url": "https://shop.example.com/checkouts/abc"
  },
  "idempotency_key": "cart-abc-20261021"
}