Skip to content

EmailTemplateManager

Email Template Manager

Manages email templates for authentication and user communication. Supports customizing templates for magic links, email verification, password resets, and user invitations.

const templates = client.admin.emailTemplates
// List all templates
const { templates: allTemplates } = await templates.list()
// Get specific template
const magicLink = await templates.get('magic_link')
// Update template
await templates.update('magic_link', {
subject: 'Sign in to ' + '{{.AppName}}',
html_body: '<html>Custom template with ' + '{{.MagicLink}}' + '</html>',
text_body: 'Click here: ' + '{{.MagicLink}}'
})
// Test template (sends to specified email)
await templates.test('magic_link', 'test@example.com')
// Reset to default
await templates.reset('magic_link')

new EmailTemplateManager(fetch): EmailTemplateManager

ParameterType
fetchFluxbaseFetch

EmailTemplateManager

get(type): Promise<EmailTemplate>

Get a specific email template by type

ParameterTypeDescription
typeEmailTemplateTypeTemplate type (magic_link

Promise<EmailTemplate>

Promise resolving to EmailTemplate

const template = await client.admin.emailTemplates.get('magic_link')
console.log(template.subject)
console.log(template.html_body)

list(): Promise<ListEmailTemplatesResponse>

List all email templates

Promise<ListEmailTemplatesResponse>

Promise resolving to ListEmailTemplatesResponse

const response = await client.admin.emailTemplates.list()
console.log(response.templates)

reset(type): Promise<EmailTemplate>

Reset an email template to default

Removes any customizations and restores the template to its original state.

ParameterTypeDescription
typeEmailTemplateTypeTemplate type to reset

Promise<EmailTemplate>

Promise resolving to EmailTemplate - The default template

const defaultTemplate = await client.admin.emailTemplates.reset('magic_link')

test(type, recipientEmail): Promise<void>

Send a test email using the template

Useful for previewing template changes before deploying to production.

ParameterTypeDescription
typeEmailTemplateTypeTemplate type to test
recipientEmailstringEmail address to send test to

Promise<void>

Promise

await client.admin.emailTemplates.test('magic_link', 'test@example.com')

update(type, request): Promise<EmailTemplate>

Update an email template

Available template variables:

  • magic_link: {{.MagicLink}}, {{.AppName}}, {{.ExpiryMinutes}}
  • verify_email: {{.VerificationLink}}, {{.AppName}}
  • reset_password: {{.ResetLink}}, {{.AppName}}, {{.ExpiryMinutes}}
  • invite_user: {{.InviteLink}}, {{.AppName}}, {{.InviterName}}
ParameterTypeDescription
typeEmailTemplateTypeTemplate type to update
requestUpdateEmailTemplateRequestUpdate request with subject, html_body, and optional text_body

Promise<EmailTemplate>

Promise resolving to EmailTemplate

const updated = await client.admin.emailTemplates.update('magic_link', {
subject: 'Your Magic Link - Sign in to ' + '{{.AppName}}',
html_body: '<html><body><h1>Welcome!</h1><a href="' + '{{.MagicLink}}' + '">Sign In</a></body></html>',
text_body: 'Click here to sign in: ' + '{{.MagicLink}}'
})