> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Template variables reference

> The full syntax of notification templates: common variables, event variables from the payload schema, format helpers, what replaces conditional blocks, escaping and validation.

## What it is for

The [Variables](https://docs.bbrands.io/enterprise/notifications/templates/variables.md) page explains how to insert a variable in the
editor. This page is the complete reference of what a template can write between double braces, where each value
comes from and what happens when it is missing.

## Common variables

Every template of every event can use these five, whatever data the event carries.

| Variable | What it puts | When it is empty |
| - | - | - |
| `{{account.name}}` | The name of the recipient's account | The recipient has no account, for example a send to a bare address |
| `{{recipient.first_name}}` | The recipient's first name: the one the campaign segment gives, else the profile's, else the account name | Neither the profile nor the account has a name |
| `{{recipient.email}}` | The email address the email channel uses for this recipient | The recipient has no email |
| `{{brand.name}}` | The name of the event's brand: BBrands, Maihue, Maihue Lunch or MaihueGO | Never |
| `{{links.preferences}}` | A signed link that opens the customer's notification preferences, or unsubscribes in one click | The event cannot be turned off (security, transactional, payment, system), so there is nothing to unsubscribe from |

> [!NOTE]
>
> There are exactly five common variables. Any other name must come from the event's data.

## Event variables

The rest of the variables are the event's data (its payload). Each event declares in the code the shape of its
data, the **payload schema**: which fields it carries, their type and which are required. That schema decides:

* which variables the editor offers in the **Variables** card;
* which variables a template may use: publishing fails when a template uses a field the schema does not declare;
* the sample data of the preview and of the test send.

The fields of each event are on its page under [Events](https://docs.bbrands.io/enterprise/notifications/events/index.md), in the "Template
variables" table, with the sensitive ones marked.

| Write | Means |
| - | - |
| `{{couponName}}` | A top-level field of the data |
| `{{coupon.expiresAt}}` | A field inside another field (dotted path) |
| `{{items.0.name}}` | The first element of a list, by its position (starting at 0) |

A field that the schema declares but that a given firing does not carry prints as empty text.

## Format helpers

A helper goes before the variable, inside the same braces. There are four; any other word is not a helper.

| Write | Result | Notes |
| - | - | - |
| `{{date coupon.expiresAt "long"}}` | The date in words, for example "15 de noviembre de 2026" | Styles: `"long"`, `"short"` or `"datetime"` (date and time) |
| `{{money amount}}` | The amount with the currency format, for example "\$12.990" | Pesos (CLP) by default; a field with `amount` and `currency` uses its currency |
| `{{upper merchantName}}` | The text in capitals | |
| `{{list benefits "✓ "}}` | Each item of a list on its own line, after the optional prefix | Empty items are skipped and an empty list prints nothing. In the email body each line is escaped and separated with a line break; in the other bodies, with a new line. In one-line fields (email subject, preheader and sender, titles, button labels) the items are joined with a comma |

Dates and amounts use the recipient's language (es-CL, en-US, fr-FR, it-IT or pt-BR) and timezone. A recipient
without a timezone uses America/Santiago.

## Conditional blocks

Templates have **no conditional blocks or loops**: there is no `{{#if}}`, `{{#each}}` or `{{else}}`. The syntax is
only `{{path}}` and the four helpers. That is on purpose: a business user can read any template from top to
bottom and the preview always shows every line.

When a text depends on a condition, use one of these instead:

| Need | What to do |
| - | - |
| A line that only makes sense with a value | Write the sentence so that it still reads well when the value is empty |
| Two different messages for two situations | Ask Technology for two events (for example, "coupon obtained" and "coupon about to expire"), each with its own template |
| A list of items | Use `{{list path "✓ "}}`: one line per item, as many as the list has |
| A sentence that changes with the data (the expiry of a coupon, where a voucher is used) | Technology sends it already written in the five languages, one field per language: write `{{redemption_sentence.es}}` in the Spanish text, `{{redemption_sentence.en}}` in the English one, and so on. It may come empty, so write the text around it to read well either way |
| A different text per language | Use the template's languages, not a condition |

## Escaping and safety

| Rule |
| - |
| In the email body, values are escaped: a name with `<` or `&` shows as written and cannot break the design or inject a link |
| The rendered email body is sanitised again before it is sent |
| Subjects, push texts and in-app texts are plain text: values are inserted as they are |
| Sensitive fields (for example a code or a token) reach the customer in the message, but Horizon stores them as `[redacted]` in the occurrence |

## Validation

| When | What is checked | What happens if it fails |
| - | - | - |
| While you edit | Every variable exists in the event or is common | "Unknown variables: …" under the texts |
| On publish | The same, in every language, plus the channel limits with the longest sample data | Publishing is blocked with the field and the language |
| On every send | The text renders and fits the channel's limits | The send is skipped with the reason **Invalid content** |

## Email and in-app layout

* **Email.** The body you write is wrapped in the brand's layout (logo, colours, footer). The footer adds the
  unsubscribe link from `{{links.preferences}}` when the event can be turned off, and a plain-text version is built
  automatically.
* **Images.** An image whose address changes per environment, such as the icon of the coupon emails, arrives as a
  variable: write `<img src="{{icon_url}}">`. The address must start with `https:`; otherwise the image is shown
  without it.
* **In-app.** The text is rendered when the send is created, in the recipient's language, and stored ready to show
  in the inbox. There is no separate layout.

## Technical detail

| Aspect | Detail |
| - | - |
| Common variables and syntax | `IMPLICIT_TEMPLATE_VARIABLES`, `TEMPLATE_HELPERS` and `TEMPLATE_EXPRESSION` in `backend/horizon-api/lib/notification/template/render/template-variables.ts` |
| Helpers | `backend/horizon-api/lib/notification/template/render/template-helpers.ts` |
| Render and contracts | `backend/horizon-api/lib/notification/template/render/notification-render.ts`; sanitiser `html-sanitizer.ts` |
| Values of the common variables | `eligibility-pipeline.ts`, step 7.4 |
| Payload schema | `payloadSchema` of each event in `backend/horizon-api/lib/notification/event/registry/` |
| Sentences written per language | `backend/horizon-api/lib/notification/producers/notification-phrases.ts` (`expiry_sentence`, `savings_sentence`, `redemption_sentence`, …), sent by each producer |
| Brand layout | `backend/horizon-api/lib/email/shared/brand-layout.ts` |

## Related and history

* [Variables in the editor](https://docs.bbrands.io/enterprise/notifications/templates/variables.md)
* [Preview and test](https://docs.bbrands.io/enterprise/notifications/templates/preview-and-test.md)
* [States and reasons](https://docs.bbrands.io/enterprise/notifications/reference/states-and-reasons.md)

| Date | Change |
| - | - |
| 2026-11-11 | First version |
| 2026-11-12 | Sentences written per language by Technology and image variables (`icon_url`) of the coupon emails (maihue/club-benefits D-51) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.