Skip to main content

Notification Templates

The OTPs, invitations, magic links, password recovery links, and CIBA approval messages your flows send all come from notification templates. A notification template is the content ThunderID sends on one channel: the subject and body of an email, or the body of an SMS. You manage templates while the server runs, from the Console or the Notification Templates API, so an edit takes effect on the next send with no file to touch and no restart.

The content is not fixed text. It carries placeholders that ThunderID resolves when the message goes out, drawing on translations, the applicable design, and the values the flow produced.

Prerequisites​

  • ThunderID is running. See Get ThunderID.
  • An access token with the system:notificationtemplate scope to change templates, or system:notificationtemplate:view to read them.
  • For delivery, an email provider or SMS provider, selected on the flow's notification step.

Manage Templates​

Templates live in the config database, and you work with them from the Console or over the API.

In the Console, open Customize → Notifications, which splits into Email Templates and SMS Templates. On the control plane, open the project first: Notifications is under Customize and lists the templates of that project. Use New template to create one, or open an existing template to edit its display name, description, content, and, for email, its light or dark color scheme. Preview the result before you save. You can delete a template, unless a flow still references it. Import / Export moves templates as declarative resources for a GitOps workflow.

Over the API, manage templates under /notification-templates/{channel}/templates, where {channel} is email or sms:

MethodPathDescription
GET/notification-templates/{channel}/templatesList the channel's templates.
POST/notification-templates/{channel}/templatesCreate a template.
GET/notification-templates/{channel}/templates/{id}Read a template.
PUT/notification-templates/{channel}/templates/{id}Update a template. The handle does not change.
DELETE/notification-templates/{channel}/templates/{id}Delete a template, unless a flow references it.

By default a template is a database row you edit freely through the Console and API, and any template declared in a file is merged in as a read-only entry. To keep templates in version control only, set notification.template.store to declarative, where templates come from files alone and the API and Console refuse writes with a 403. To use the database alone and ignore file-declared templates, set it to mutable. See Import Declarative Resources.

Templates in Projects​

On the control plane, every notification template belongs to a project.

  • Create: set projectId in the request body of POST /notification-templates/{channel}/templates. Without ouId, the template goes into the system organization unit. With ouId, it must be the system organization unit or an organization unit of the project. A request without projectId fails with NTM-1031, a project that does not exist fails with NTM-1029, and any other organization unit fails with NTM-1030.
  • List: GET /notification-templates/{channel}/templates?projectId=<project-id> returns the templates of the project. A project that does not exist returns an empty list.
  • Update: an update without projectId keeps the template in its current project. A different projectId moves the template to that project. A project that does not exist fails with NTM-1029, and a template can move into a project only from the system organization unit or an organization unit of that project (NTM-1030).
  • Delete a project: deleting a project that still has templates fails with PRJ-1013.
  • Declarative files: a template file must set projectId, and can leave ouId out to be placed in the system organization unit. A file without projectId stops the server from starting. Export and import keep projectId.

The built-in templates belong to the Default project. A flow finds its template by handle, and handles are unique across the deployment, so a flow in another project can use them. A deploy of a project sends only its own resources, so deploy the Default project to a gateway before projects whose flows use its templates.

A server without projects, such as the all-in-one server, does not require a project and keeps the projectId it receives without checking it.

Writing Template Content​

An email template has a subject and a body; an SMS template has a body only. Each field is text with three kinds of placeholder, which ThunderID resolves in order, translations first, then design, then the runtime values:

  • {{t(key)}} resolves to translated text from the notification translation namespace, so you author one template rather than one copy per language.
  • {{design(token)}} resolves a design token, such as {{design(palette.primary.main)}}, against the applicable theme. It is allowed only in an email body, never in a subject or in SMS.
  • {{ctx(key)}} resolves to a value the sender supplies at send time, such as {{ctx(otpCode)}}.

The placeholder syntax has a few limits to account for when writing a template:

  • Keys are case sensitive. {{ctx(otpCode)}} resolves; {{ctx(otpcode)}} does not.
  • There are no filters, defaults, conditionals, or loops. Placeholders are substituted as-is, so anything conditional belongs in a different template.
  • Rendering is fail-closed. If a referenced translation key, a {{design(...)}} token, or a {{ctx(...)}} value cannot be resolved, ThunderID does not send the message and reports the error, rather than delivering it with a raw {{...}} left in place. A typo in a key name stops the send instead of reaching the user.

That last point is why context tokens need care: a {{ctx(...)}} placeholder only resolves if something earlier produced its value, and referencing one that nothing supplies fails the send. The token catalog lists every token you can insert and, for context tokens, which values each scenario guarantees.

Content is also checked when you save it. A malformed or unsupported placeholder, or a {{design(...)}} token in a subject or in SMS, is rejected before the template is stored. This catches syntax and channel mistakes at save time; whether every {{ctx(...)}} value actually resolves is known only at send time, where an unresolved one fails the send as described above.

The Values a Sender Supplies​

The runtime supplies a set of {{ctx(...)}} values, and each sending scenario guarantees at least a few of them. See Context Tokens in the token catalog for the complete list and the per-scenario availability.

These are the values a handle guarantees, not the complete set. A template rendered inside a flow can also use whatever the flow already holds. The recipient's user claims, such as {{ctx(mobile_number)}}, and any runtime data the flow produced are available as {{ctx(...)}} values too. The exception is the standalone SMS OTP endpoint, which runs outside a flow and supplies only otpCode and expiryTime.

In an HTML email body, ThunderID HTML-escapes each {{ctx(...)}} value before inserting it, so a value that contains < or & reads as text rather than markup. Translation and design results are content you authored, and are not escaped.

Localizing and Theming​

Because copy is written as {{t(...)}} keys rather than literal text, wording stays out of the template and lives in the notification translation namespace. Create and edit those keys from the editor's token panel or the Console Translations page. ThunderID currently renders every notification in the system default language, en-US, falling back to the nearest available value for a key; sending each recipient their own language is an upcoming enhancement. For email, {{design(...)}} tokens resolve against the chosen theme and color scheme, so a template follows your branding without carrying a copy of it. The token catalog lists the design and translation tokens you can insert.

The Standalone SMS OTP Endpoint​

POST /auth/otp/sms/send renders the otp SMS template outside of any flow. Because no flow is running, there is no application, user, or identity provider to draw from, and the endpoint supplies only two values:

  • otpCode
  • expiryTime

Keep the otp SMS template to those two keys. Any other {{ctx(...)}} placeholder has nothing to resolve against, and because rendering is fail-closed, it stops the send.

SMS Length​

An SMS segment holds 160 characters. When a rendered SMS body exceeds that, ThunderID logs a warning and still sends the message; the provider then splits it into multiple segments, which most providers bill separately.

Write SMS bodies against the rendered length, not the template length. A body that looks short can grow well past 160 characters once a long inviteLink or a long appName is substituted in.

Next Steps​

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.