Configure automation email
Configure the email that fires for a registered automation event. Supports three payload shapes:
- Toggle —
{ event, active }enables/disables the automation. On a creator-global save (nomango) it cascades the flag to every per-mango row for the event. - Content save —
{ event, subject, template }(plus optionalmango/active) writes template content. Omitmangoto set the creator-global template; providemangoto set a per-mango override. - Per-mango override — any save containing
mangoauto-enables the creator-global row (so a per-mango override always has a backing enabled event). Callers do not need to pre-toggle the event separately.
Partial updates: subject, template, and active are all optional. Fields absent from the body are preserved on the stored record. At least one of active, template, or subject must be present.
Processing:
- HTML sanitization —
<script>,<iframe>, event handlers (onclick/onerror/…), andjavascript:URLs are rejected. Full HTML documents (<html>/<head>/<body>wrappers) are accepted; wrappers are stripped and any<head><style>blocks are preserved. - Handlebars compile-test — template is compiled against the event's allowed variable catalogue; unknown variables are rejected.
- Unlayer design synthesis — a minimal visual-editor design is generated from the HTML so the template remains editable in the dashboard editor.
- Cascade writes — creator-global saves cascade
activeto per-mango rows; per-mango saves auto-enable the creator-global row.
Authorization
bearer In: header
Header Parameters
Host name of the dashboard, ex: mydomain.tagmango.com
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://api-prod-new.tagmango.com/api/v1/external/automations/emails/templates" \ -H "x-whitelabel-host: string" \ -H "Content-Type: application/json" \ -d '{ "event": "mangoPurchase" }'{
"_id": "69c77c57ad85cea56909a95e",
"creator": "69945193ce0ecef7256a481f",
"mango": "69bcc993473291fad8e4a7fa",
"event": "mangoPurchase",
"subject": "Your {{{mango}}} purchase is confirmed",
"template": "<p>Hey {{{name}}}, thanks for buying <strong>{{{mango}}}</strong>!</p>",
"active": true,
"createdAt": "2026-04-23T11:17:44.000Z",
"updatedAt": "2026-04-23T11:17:44.000Z"
}{
"code": 400,
"type": "Bad Request",
"statusMessage": "BAD_REQUEST",
"errorCode": "AUTOMATION_TEMPLATE_TOO_LARGE",
"message": "HTML templates are capped at 256 KB after UTF-8 encoding.",
"result": "HTML templates are capped at 256 KB after UTF-8 encoding.",
"success": false
}{
"code": 401,
"type": "Unauthorized",
"statusMessage": "UNAUTHORIZED",
"message": "Invalid token",
"result": "Invalid token",
"success": false
}{
"code": 403,
"type": "Forbidden",
"statusMessage": "FORBIDDEN",
"errorCode": "AUTOMATION_USER_NOT_CREATOR",
"message": "The user has not completed creator onboarding or is not a valid creator account.",
"result": "The user has not completed creator onboarding or is not a valid creator account.",
"success": false
}{
"code": 404,
"type": "Not Found",
"statusMessage": "NOT_FOUND",
"errorCode": "AUTOMATION_CREATOR_NOT_FOUND",
"message": "The creator associated with the API key does not exist.",
"result": "The creator associated with the API key does not exist.",
"success": false
}{
"code": 429,
"type": "Too Many Requests",
"statusMessage": "TOO_MANY_REQUESTS",
"message": "Request limit exceeded. try after 10 seconds",
"result": "Request limit exceeded. try after 10 seconds",
"success": false
}