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.
Example
Section titled “Example”const templates = client.admin.emailTemplates
// List all templatesconst { templates: allTemplates } = await templates.list()
// Get specific templateconst magicLink = await templates.get('magic_link')
// Update templateawait 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 defaultawait templates.reset('magic_link')Constructors
Section titled “Constructors”new EmailTemplateManager()
Section titled “new EmailTemplateManager()”new EmailTemplateManager(
fetch):EmailTemplateManager
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | FluxbaseFetch |
Returns
Section titled “Returns”Methods
Section titled “Methods”get(
type):Promise<EmailTemplate>
Get a specific email template by type
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type | EmailTemplateType | Template type (magic_link |
Returns
Section titled “Returns”Promise<EmailTemplate>
Promise resolving to EmailTemplate
Example
Section titled “Example”const template = await client.admin.emailTemplates.get('magic_link')console.log(template.subject)console.log(template.html_body)list()
Section titled “list()”list():
Promise<ListEmailTemplatesResponse>
List all email templates
Returns
Section titled “Returns”Promise<ListEmailTemplatesResponse>
Promise resolving to ListEmailTemplatesResponse
Example
Section titled “Example”const response = await client.admin.emailTemplates.list()console.log(response.templates)reset()
Section titled “reset()”reset(
type):Promise<EmailTemplate>
Reset an email template to default
Removes any customizations and restores the template to its original state.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type | EmailTemplateType | Template type to reset |
Returns
Section titled “Returns”Promise<EmailTemplate>
Promise resolving to EmailTemplate - The default template
Example
Section titled “Example”const defaultTemplate = await client.admin.emailTemplates.reset('magic_link')test()
Section titled “test()”test(
type,recipientEmail):Promise<void>
Send a test email using the template
Useful for previewing template changes before deploying to production.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type | EmailTemplateType | Template type to test |
recipientEmail | string | Email address to send test to |
Returns
Section titled “Returns”Promise<void>
Promise
Example
Section titled “Example”await client.admin.emailTemplates.test('magic_link', 'test@example.com')update()
Section titled “update()”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}}
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type | EmailTemplateType | Template type to update |
request | UpdateEmailTemplateRequest | Update request with subject, html_body, and optional text_body |
Returns
Section titled “Returns”Promise<EmailTemplate>
Promise resolving to EmailTemplate
Example
Section titled “Example”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}}'})