Skip to content

Email templates

Open Authentication → Email templates (or PATCH /v1/projects/{ref}/config/auth with email_templates) to customize the subject, HTML and text of each auth email:

invite, magic_link, recovery, verify_email, otp, tenant_invite.

Missing kinds or fields keep the built-in template.

Variables use Go-template syntax:

Variable Value
{{ .ConfirmationURL }} the link of the email (invite, magic link, recovery, verify, tenant invite)
{{ .Token }} the OTP code (otp), or the token carried by the link
{{ .Email }} recipient
{{ .SiteURL }} the project’s site URL
{{ .RedirectTo }} the validated redirect target (invite, magic link, tenant invite)
{{ .Data.<key> }} the user’s user_metadata.<key> (for example data passed to an invite)
{{ .TenantName }}, {{ .Role }} tenant invitations

Only plain substitution exists: no if, range, pipelines or helpers, so a template can never run code. In the HTML body every value is HTML-escaped (URLs included); text bodies get raw values; line breaks are removed from the subject. Unknown variables render empty.

The html of a template is the content fragment only: heading, text and buttons, without <html> or <body>. PotaLab Base places it inside a standard email-safe layout (table based, inline CSS, max 600 px wide, mobile friendly, light and dark aware):

  • a header with your project name;
  • your content;
  • a footer with “If you didn’t request this, you can ignore this email.”, “Sent by (your project name) - Powered by PotaLab Base” and a link to your site.

The footer branding is always added and cannot be removed by a template. The subject is used as hidden preheader text. The class base-btn styles a primary button.

<h1>Welcome back</h1>
<p>Use the link below to sign in to {{ .SiteURL }}.</p>
<p><a class="base-btn" href="{{ .ConfirmationURL }}">Sign in</a></p>

When you customize the HTML but not the text body, the text part is derived from the rendered HTML. The dashboard preview renders your template with sample values inside the full layout.

Auth emails ship in English (en, the default) and Vietnamese (vi). Add your own wording per language with locales next to the default template, and pick the project default with default_locale:

{
"default_locale": "en",
"email_templates": {
"magic_link": {
"subject": "Sign in to Example",
"locales": {
"vi": { "subject": "Dang nhap Example", "html": "<p><a class=\"base-btn\" href=\"{{ .ConfirmationURL }}\">Dang nhap</a></p>" }
}
}
}
}

Send it with PATCH /v1/projects/{ref}/config/auth. Up to 20 locale tags per kind, written as short BCP 47 tags (vi, pt-br), stored in lowercase. Fields you leave out of a locale use the built-in text of that language, then English.

The language is chosen when the email is sent, in this order, and the first one that has a variant wins (vi-VN also tries vi):

  1. locale in the recipient’s user_metadata
  2. the Accept-Language header of the request, only for emails the recipient asked for themselves (magic_link, recovery, verify_email, otp); invite and tenant_invite ignore it because someone else triggers them
  3. the project’s default_locale
  4. en

The template fields without locales are the variant of default_locale. A user whose language differs gets the built-in text of their language, not your customized default; add locales[tag] for every language you want to customize. The layout around your content (footer text, <html lang>) follows the language too. The preview endpoint POST /v1/projects/{ref}/auth/email-templates/preview accepts an optional locale. The text part of a variant you customize in HTML only is derived from the rendered HTML.