Skip to Content
Notification APIDocs

Templates and variables

Reuse content managed in the dashboard and personalize it with variables.

A message template is reusable content managed in the dashboard (Templates). Templates belong to the project and to one provider, which fixes their channel. With an API key you can list and read them, and send messages with templateId.

Template fields

FieldMeaning
contentThe body, with {{ placeholders }}.
contentTypeHtml, Text, Markdown or Json.
subjectOptional subject (email), may contain placeholders.
dataOptional provider-specific JSON object (for example push payload data); its string values may contain placeholders.
schemaJSON form schema describing the variables. Informational: it is not used to validate a send request.
attachmentsFiles attached to every message sent with the template (email).

Placeholders

Placeholders are written {{key}} or {{ key }}. Keys may contain letters, digits, _, . and - and are case-sensitive ({{ firstName }} and {{ firstname }} are different).

<p>Hi {{ firstName }}, your order {{ order.id }} has shipped.</p>

Values are strings. In Html templates, values are HTML-encoded in the body, so a value like <b> is shown as text and cannot inject markup. Subjects and data values are inserted as they are.

Message and recipient variables

Values come from two places:

  • variables on the message apply to every recipient.
  • variables on a recipient apply to that recipient only and override message variables with the same key.
{
  "channel": "email",
  "templateId": "0197a5f0-2b1c-7e44-8a55-1c2d3e4f5a6b",
  "variables": { "storeName": "Acme" },
  "recipients": [
    { "type": "Email", "value": "jane@example.com", "variables": { "firstName": "Jane" } },
    { "type": "Email", "value": "john@example.com", "variables": { "firstName": "John" } }
  ]
}

A message can carry at most 100 message-level variables.

Missing variables

Every placeholder must get a value. If a placeholder is left without one for any recipient, the request is rejected with 422 message.missing_variables, and the error title lists the missing keys:

{ "status": 422, "title": "Template variables are missing: firstName, order.id.", "code": "message.missing_variables" }

Nothing is sent in that case.

Overriding template parts

content, subject and data in the request override the template's own values, while placeholders in them are still filled in. Template attachments are always included.

Template and channel

The template must belong to your project and to the channel of the request; otherwise the API answers 404 message.template_not_found. Use the channel filter of List templates to find the templates of a channel.

Sending without a template

Without templateId, content is required and the message is sent exactly as given: placeholders are not rendered. Build the final text in your application, or use a template.

On this page