Email Templates API
The Email Templates API lets administrators customize the transactional emails sent by Auris. Each of the thirteen template types corresponds to a specific event (verification, password reset, magic link, security alerts, …) and can be customized with HTML and dynamic variables, independently per locale, either for the whole tenant or for one application.
Breaking changes
DELETE /api/email-templates/{type}now requires thelocalequery parameter and resets only that locale. Withoutlocaleit returns422; it no longer deletes every locale of the type.PUT /api/email-templates/{type}returns422(previously400) whensubjectorhtmlBodyis missing or invalid.PUTdefaults toaction: "publish". Publishing runs a pre-publish check and returns422when it fails (unknown variables, a missing required link or code variable). Sendaction: "draft"to save incomplete work without publishing it. Optional conflict-check tokens return409when the document changed in another session.defaultSubjectanddefaultHtmlBodyinGET /api/email-templates/{type}now return the effective published template that a live send would use, not always the built-in template.- New applications default to
emailTemplateInheritance: falseand do not use the tenant’s custom templates. Applications that already existed in tenants with custom templates were migrated totrue. PATCH /api/email-templates/applications/{applicationId}requiresadmin:all.
Scope and delivery order
Templates belong either to the tenant or to one application. Pass the applicationId query parameter (or applicationId in the request body; if both are given they must match, otherwise 422) to work on an application’s templates. Without it, requests apply to the tenant’s templates. An unknown, inactive, or foreign application returns 404.
Auris ships with default templates for all types in five locales (en, it, fr, de, es). When an email is sent for an application, the template is resolved in this order:
- The application’s published template (requested locale, then
en). - The tenant’s published template (requested locale, then
en), only when the application’semailTemplateInheritanceistrue. - The built-in default (requested locale, then
en), rendered with the application’s or tenant’s branding.
Emails sent without an application use the tenant’s published template, then the built-in default. Drafts are never used for delivery.
All endpoints select the tenant via the x-tenant header (the tenant’s realm identifier) and require a Bearer token with the manage:security permission, except PATCH /api/email-templates/applications/{applicationId}, which requires admin:all.
These endpoints return plain JSON objects — they do not use the { ok, data } envelope found in
other parts of the Auris API.
List Templates
/api/email-templatesRequires: manage:securityList all thirteen template types with their customization status for the tenant. Full HTML bodies are not included — fetch a single template for that.
Success response (200)
{
"templates": [
{
"type": "verification",
"label": "Email Verification",
"description": "Sent when a new user registers to verify their email address.",
"variables": ["email", "link", "expiresIn", "year", "month", "day", "date"],
"hasCustomTemplate": true,
"active": true,
"updatedAt": "2026-07-20T10:00:00.000Z",
"customLocales": ["en", "it"]
}
],
"applicationId": null,
"availableLocales": ["en", "it", "fr", "de", "es"],
"wellKnownLocales": { "en": "English", "it": "Italiano", "pt-BR": "Português (Brasil)" }
}The list covers the scope selected by applicationId (null for the tenant).
Get Template
/api/email-templates/{type}?locale={locale}Requires: manage:securityGet a template for one locale: the custom content (if any) plus the branded default baseline. The locale query parameter defaults to en.
Success response (200)
{
"type": "verification",
"locale": "it",
"label": "Email Verification",
"description": "Sent when a new user registers to verify their email address.",
"variables": ["email", "link", "expiresIn", "year", "month", "day", "date"],
"hasCustomTemplate": false,
"subject": null,
"htmlBody": null,
"metadata": null,
"active": true,
"updatedAt": null,
"defaultSubject": "Verifica il tuo indirizzo email",
"defaultHtmlBody": "<!DOCTYPE html>...",
"availableLocales": ["en", "it", "fr", "de", "es"],
"customLocales": ["en"],
"hasDefaultTemplate": true,
"wellKnownLocales": { "en": "English", "it": "Italiano" }
}subject, htmlBody, and metadata are null when no custom template exists for the requested locale in the selected scope. defaultSubject and defaultHtmlBody contain the effective published template that a live send would use, following the delivery order above (application, then tenant when inheritance is on, then built-in). They fall back to the built-in template, rendered with the branding (logo, color, white-label footer) a live send would use, only when no published template applies. effectiveSource (application, tenant, or default) and effectiveLocale say where it came from. hasDefaultTemplate indicates whether the requested locale has a built-in default (en, it, fr, de, es); other locales fall back to English.
The response also includes the current draft (or null), the latest revisions, documentVersion, applicationId, tenantId, requiredVariables, textBody, emailTheme, and emailTemplateInheritance.
Error responses
Update Template
/api/email-templates/{type}Requires: manage:securitySave a draft or publish the custom template for one locale. The locale can be passed in the body or as a query parameter; it defaults to en. Only a published template is used for delivery.
Request body
{
"subject": "Verify your email — {{email}}",
"htmlBody": "<!DOCTYPE html><html><body><h1>Verify your email</h1><p>Hello {{email}},</p><p><a href=\"{{link}}\">Confirm your address</a></p><p>The link expires in {{expiresIn}}.</p></body></html>",
"locale": "en",
"metadata": { "source": "code" }
}Publishing requires a non-empty subject and body, rejects unknown {{variables}}, and requires the type’s link or code variable (for example {{link}} for magic_link, {{code}} for mfa_code). Any conflict-check token that no longer matches returns 409 and nothing is saved; reload and retry. Publishing stores the previous and new published versions in the revision history and clears the draft.
The HTML body is sanitized on the server before storage: <script> tags, event handler attributes (onclick, …), javascript:/data: URIs, <iframe>/<embed>/<object>/<form>/<base> tags, and dangerous CSS constructs are stripped.
Success response (200) — for publish, the published template record (plus revision: 0 and the new documentVersion); for draft, the draft record (with its revision) and documentVersion:
{
"id": "cltpl123",
"tenantId": "tnt_ScUtrVKUKGxtu7WY",
"type": "verification",
"locale": "en",
"subject": "Verify your email — {{email}}",
"htmlBody": "<!DOCTYPE html>...",
"metadata": { "source": "code" },
"active": true,
"createdAt": "2026-07-23T09:00:00.000Z",
"updatedAt": "2026-07-23T09:00:00.000Z"
}Error responses
A published template takes effect immediately for all future emails of this type, locale, and scope. Save a draft and preview or test it before publishing.
Reset Template
/api/email-templates/{type}?locale={locale}Requires: manage:securityReset one locale of the template in the selected scope: the published template and its draft are removed, and the previous published version is kept in the revision history. The locale query parameter is required.
After a reset, delivery follows the delivery order above (tenant template when inheritance is on, otherwise the built-in default).
Success response (200)
{ "success": true, "documentVersion": 3 }Revision History
/api/email-templates/{type}/revisions?locale={locale}Requires: manage:securityReturn the current draft, the 30 most recent revisions (id, subject, createdAt, active), and the documentVersion for one locale. Supports the applicationId query parameter.
Success response (200)
{
"draft": null,
"revisions": [{ "id": "clrev123", "subject": "Sign in", "createdAt": "2026-10-08T09:00:00.000Z", "active": true }],
"documentVersion": 2
}/api/email-templates/{type}/revisionsRequires: manage:securityRestore a revision into the draft. Nothing is published until the draft is published with PUT.
Request body
{ "locale": "en", "revisionId": "clrev123", "applicationId": "app_123", "expectedRevision": 0, "expectedDraftId": null, "expectedDocumentVersion": 2 }locale and revisionId are required; the conflict-check tokens are optional. Returns the draft record and documentVersion. Errors: 404 unknown revision or application, 409 conflict, 422 invalid request.
Applications
/api/email-templates/applicationsRequires: manage:securityList the tenant’s active applications with their email profile and inheritance setting.
Success response (200)
{ "applications": [{ "id": "app_123", "name": "Portal", "emailTheme": null, "emailTemplateInheritance": false }] }/api/email-templates/applications/{applicationId}Requires: admin:allUpdate an application’s email profile (theme) and template inheritance.
Request body (all fields optional; other fields are rejected)
{ "emailTemplateInheritance": true, "emailTheme": { "content": { "brandName": "Portal" } } }Returns { "success": true }. Errors: 403 without admin:all, 404 unknown application, 413 body over 100,000 characters, 422 invalid profile.
Preview Template
/api/email-templates/{type}/previewRequires: manage:securityRender a subject and HTML body with realistic sample variables for the template type. Nothing is sent and nothing is stored.
Request body
{
"subject": "Verify your email — {{email}}",
"htmlBody": "<!DOCTYPE html>..."
}Success response (200)
{
"subject": "Verify your email — [email protected]",
"html": "<!DOCTYPE html>...",
"variables": {
"email": "[email protected]",
"link": "https://console.auris.dev/verify-email?token=abc123",
"expiresIn": "24 hours",
"year": "2026",
"month": "07",
"day": "23",
"date": "2026-07-23"
}
}The variables field echoes the sample values that were substituted. The HTML body is sanitized before rendering; the subject is rendered as plain text (no HTML escaping of values).
Test Email
/api/email-templates/{type}/testRequires: manage:securityRender the given subject and HTML body with sample data and send them as a real email. By default the email goes to the authenticated administrator’s own address.
Request body
{
"subject": "Verify your email — {{email}}",
"htmlBody": "<!DOCTYPE html>...",
"recipientEmail": "[email protected]"
}Success response (200)
{ "success": true, "sentTo": "[email protected]" }Error responses
The rendered subject is prefixed with [TEST] so test emails are easy to distinguish from real
transactional mail. Delivery uses the tenant’s SMTP configuration when present and active, otherwise
the platform default sender.
Template Types
Auris supports thirteen transactional email template types:
The global date variables year, month, day, and date (format YYYY-MM-DD) are auto-injected into every render, in addition to the per-type variables above.
Template Syntax
{{variable}}— replaced with the value. In the HTML body, values are HTML-escaped automatically to prevent injection; in the subject line values are inserted as plain text.{{{variable}}}— raw interpolation without escaping. Only for trusted, server-built HTML fragments.{{#if variable}}...{{/if}}— the block is kept only when the variable resolves to a non-empty string; otherwise it is removed entirely (markup included). Example: themagic_linkdefault template renders the secondary approve button only whenapproveLinkis provided.
Unknown placeholders are left as-is in the output. Dot notation and loops are not supported.
<h1>Sign in to {{tenantName}}</h1>
<p><a href="{{link}}">Sign in on this device</a></p>
{{#if approveLink}}
<p><a href="{{approveLink}}">Approve on the original device</a></p>
{{/if}}
<p>The link expires in {{expiresIn}}.</p>Audit Events
Draft saves, publications, restores, resets, test sends, and application email profile changes are written to the tenant audit log with the acting user, tenant, application, template type, and locale. Template content is never recorded; test sends record only the recipient’s domain. See Webhooks for the event types (email_template.*, application.profile_updated, application.template_inheritance_changed).
Permissions Reference
Related
- Customizing Email Templates — Step-by-step template customization guide
- Email Templates — Edit templates visually from the Console