MailerAddTemplate¶
POST mailer/template
Creates an email template. Placeholders are written as {{name}} and filled from the data
object at send time; substitution escapes HTML, so a customer name with < cannot break the
layout or inject markup.
Binding a template to a triggerId turns it into an automatic notification: the module
renders and queues it whenever that platform event fires.
Access Control¶
Allowed role: admin. The template belongs to the brand of the caller.
Request¶
POST https://{broker_domain}/mailer/template
{
"name": "Deposit confirmed",
"subject": "{{name}}, your deposit is confirmed",
"preheader": "Funds are already on your account",
"html": "<p>{{name}}, we received {{amount}}.</p>",
"language": "EN",
"kind": "TRANSACTIONAL",
"triggerId": 2
}
{
"command": "MailerAddTemplate",
"extID": "1",
"data": {
"name": "Deposit confirmed",
"subject": "{{name}}, your deposit is confirmed",
"preheader": "Funds are already on your account",
"html": "<p>{{name}}, we received {{amount}}.</p>",
"language": "EN",
"kind": "TRANSACTIONAL",
"triggerId": 2
}
}
const res = await platform.MailerAddTemplate({
name: "Deposit confirmed",
subject: "{{name}}, your deposit is confirmed",
preheader: "Funds are already on your account",
html: "<p>{{name}}, we received {{amount}}.</p>",
language: "EN",
kind: "TRANSACTIONAL",
triggerId: 2
});
Request Data¶
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Template name, 1..255 characters |
description |
string | No | Free-form note |
subject |
string | Yes | Subject, 1..512 characters; supports placeholders |
preheader |
string | No | Line shown next to the subject in the inbox |
html |
string | No | HTML body with {{placeholders}} |
text |
string | No | Plain-text part; generated from the HTML when empty |
structure |
array | No | Email builder tree; the HTML is rendered from it |
language |
string | No | Language code, default EN |
triggerId |
int | No | Trigger that fires this template |
profileId |
int | No | Restrict the template to one provider profile |
kind |
enum | No | TRANSACTIONAL or MARKETING (default) |
status |
enum | No | ENABLED (default) or DISABLED |
Behavior¶
- Content can be stored either as HTML or as a builder tree (
structure). The tree is serialized through a tag and attribute allow list, so a template cannot smuggle a script into the email. - A missing
textpart is generated from the HTML at send time. An email without a text part looks like bulk mail to spam filters and is unreadable in clients that block HTML. preheaderis what the inbox shows next to the subject; leaving it empty lets the client pull the first words of the HTML instead, which is usually the unsubscribe boilerplate.
Response Data¶
{
"id": 4,
"brand": "default",
"name": "Deposit confirmed",
"description": null,
"subject": "{{name}}, your deposit is confirmed",
"preheader": "Funds are already on your account",
"html": "<p>{{name}}, we received {{amount}}.</p>",
"text": null,
"structure": null,
"language": "EN",
"kind": "TRANSACTIONAL",
"triggerId": 2,
"profileId": null,
"status": "ENABLED",
"createdAt": "2026-08-24 13:15:44"
}
Errors¶
| Code | Error | Description |
|---|---|---|
400 |
VALIDATION_ERROR |
Missing name or subject, or a field is out of range |
422 |
TEMPLATE_SYNTAX_UNSUPPORTED |
The content uses unsupported syntax, for example the old EJS tags instead of {{placeholders}} |
404 |
NOT_FOUND |
Trigger or profile not found in the brand |