Email Templates
Create reusable email bodies for workflows and campaigns
Email templates are reusable full email body templates. They render with Handlebars variables and can be used by workflows, campaigns, or both.
Delivery sender identity comes from the selected mailbox for tenant email. Platform/auth email may use the platform sender.
Create Email Template
/v1/stores/{storeId}/email-templates sdk.emailTemplate.createEmailTemplate() const template = await sdk.emailTemplate.createEmailTemplate({
key: 'newsletter-feature-update',
subject: { en: '{{subject}}' },
preheader: '{{preheader}}',
body: '<h1>{{title}}</h1><div>{{body}}</div>',
variables: [
{ key: 'subject' },
{ key: 'preheader' },
{ key: 'title' },
{ key: 'body' }
],
sample_data: {
subject: 'June update',
preheader: 'A few updates from the team.',
title: 'June update',
body: '<p>Here is what changed this month.</p>'
},
from_name: 'My Store',
from_email: 'sender-default@example.com'
});Parameters
| Name | Type | Description |
|---|---|---|
key required | string | Unique template identifier |
subject optional | Record<string, string> | Localized subject template |
body optional | string | HTML body with Handlebars variables |
preheader optional | string | Inbox preview text template |
variables optional | EmailTemplateVariable[] | Declared variables used by the template |
sample_data optional | Record<string, unknown> | Preview data and example values |
from_name required | string | Sender default metadata. Tenant delivery uses the selected mailbox. |
from_email required | string | Sender default metadata. Tenant delivery uses the selected mailbox. |
reply_to optional | string | Reply-to default metadata |
Template Variables
Templates use Handlebars syntax:
-
{{subject}}escapes text values -
{{body}}renders escaped body text -
nested variables can be referenced with paths such as
{{store.name}}Declare variables so the UI, previews, workflows, and campaigns know which values can be filled before sending.
variables: [
{ key: 'subject' },
{ key: 'body' },
{ key: 'cta_url' }
]
Preview Email Template
/v1/stores/{storeId}/email-templates/{id}/preview sdk.emailTemplate.previewEmailTemplate() const preview = await sdk.emailTemplate.previewEmailTemplate({
id: 'tmpl_abc123',
vars: {
subject: 'June update',
title: 'June update',
body: '<p>Here is what changed this month.</p>'
}
});
console.log(preview.subject, preview.html, preview.warnings);
List Email Templates
/v1/stores/{storeId}/email-templates sdk.emailTemplate.getEmailTemplates() const { items, cursor } = await sdk.emailTemplate.getEmailTemplates({
query: 'newsletter',
status: 'active',
limit: 20,
});
Update Email Template
/v1/stores/{storeId}/email-templates/{id} sdk.emailTemplate.updateEmailTemplate() await sdk.emailTemplate.updateEmailTemplate({
id: 'tmpl_abc123',
subject: { en: '{{subject}}' },
body: '<h1>{{title}}</h1><div>{{body}}</div>',
status: 'active',
});
Parameters
| Name | Type | Description |
|---|---|---|
id required | string | Template ID |
key optional | string | New key |
subject optional | Record<string, string> | Updated localized subject templates |
body optional | string | Updated HTML body |
preheader optional | string | Updated preheader |
variables optional | EmailTemplateVariable[] | Updated variable declarations |
sample_data optional | Record<string, unknown> | Updated sample data |
status optional | active | archived | Template status |
Default Templates
Every new store includes shared email templates:
| Key | Purpose |
|---|---|
order-notification-store | Order notification to store admin |
order-notification-profile | Order confirmation to profile |
order-reminder-profile | Scheduled order item reminder to profile |
contact-notification-store | Contact form submission to store admin |
subscription-confirm | Profile list double opt-in confirmation |
campaign-simple-email | Simple subject/body template for campaigns |
newsletter-basic | Newsletter or broadcast email layout |
Campaign sent messages keep their rendered subject, HTML, and text output, so editing a template later does not rewrite conversation history.