Back to arkyStore.io

Email Templates

Create and manage email templates for notifications, confirmations, and newsletters

Email templates define reusable email content for notifications, audience confirmations, and newsletters. Templates use Handlebars syntax for dynamic variables.

Create Email Template

POST /v1/stores/{storeId}/email-templates
SDK: sdk.emailTemplate.createEmailTemplate()
const template = await sdk.emailTemplate.createEmailTemplate({
key: 'order-confirmation',
subject: { en: 'Order #{{orderId}} confirmed' },
body: '<h1>Thank you!</h1><p>Your order #{{orderId}} has been confirmed.</p>',
from_name: 'My Store',
from_email: '[email protected]',
replyTo: '[email protected]',
preheader: 'Your order is confirmed',
});

Parameters

Name Type Description
key required string Unique template identifier
subject optional Record<string, string> Localized subject lines (e.g. { en: '...', de: '...' })
body optional string HTML template body with Handlebars variables
from_name required string Sender display name
from_email required string Sender email address
replyTo optional string Reply-to email address
preheader optional string Email preheader text shown in inbox previews

Response

{
  "id": "tmpl_abc123",
  "key": "order-confirmation",
  "store_id": "store_123",
  "subject": { "en": "Order #{{orderId}} confirmed" },
  "body": "<h1>Thank you!</h1><p>Your order #{{orderId}} has been confirmed.</p>",
  "from_name": "My Store",
  "from_email": "[email protected]",
  "replyTo": "[email protected]",
  "preheader": "Your order is confirmed",
  "status": "ACTIVE",
  "created_at": 1704067200,
  "updated_at": 1704067200
}

Get Email Template

GET /v1/stores/{storeId}/email-templates/{id}
SDK: sdk.emailTemplate.getEmailTemplate()

Retrieve a template by ID or by key.

// By ID
const template = await sdk.emailTemplate.getEmailTemplate({ id: 'tmpl_abc123' });

// By key
const template = await sdk.emailTemplate.getEmailTemplate({ key: 'order-confirmation' });

List Email Templates

GET /v1/stores/{storeId}/email-templates
SDK: sdk.emailTemplate.getEmailTemplates()
const { items, cursor } = await sdk.emailTemplate.getEmailTemplates({
  query: 'order',
  status: 'active',
  limit: 20,
});

Parameters

Name Type Description
query optional string Search in template keys
key optional string Filter by exact key
status optional string Filter by status (ACTIVE, ARCHIVED)
ids optional string[] Filter by specific template IDs
created_at_from optional number Filter by creation date (start)
created_at_to optional number Filter by creation date (end)
limit optional number Items per page
cursor optional string Pagination cursor
sort_field optional string Sort field
sort_direction optional asc | desc Sort direction

Update Email Template

PUT /v1/stores/{storeId}/email-templates/{id}
SDK: sdk.emailTemplate.updateEmailTemplate()
await sdk.emailTemplate.updateEmailTemplate({
  id: 'tmpl_abc123',
  subject: { en: 'Your order is on its way!' },
  body: '<h1>Shipped!</h1><p>Track your order: {{trackingUrl}}</p>',
  status: 'ACTIVE',
});

Parameters

Name Type Description
id required string Template ID
key optional string New key
subject optional Record<string, string> Updated localized subjects
body optional string Updated HTML body
from_name optional string Updated sender name
from_email optional string Updated sender email
replyTo optional string Updated reply-to
preheader optional string Updated preheader
status optional ACTIVE | ARCHIVED Template status

Delete Email Template

DELETE /v1/stores/{storeId}/email-templates/{id}
SDK: sdk.emailTemplate.deleteEmailTemplate()
await sdk.emailTemplate.deleteEmailTemplate({ id: 'tmpl_abc123' });
Note

If an audience uses this template for double opt-in confirmation, the reference is automatically cleared and the audience falls back to single opt-in.

Template Variables

Templates use Handlebars syntax ({{variable}}). Available variables depend on the context:

Audience Confirmation

  • {{confirm_url}} — URL the subscriber clicks to confirm

Notification Trigger

Any custom variables you pass via sdk.notification.trigger():

await sdk.notification.trigger({
  channel: 'email',
  storeId: 'store_123',
  email_template_id: 'tmpl_abc123',
  audience_id: 'aud_newsletter', // send to all subscribers
  vars: {
    title: 'Weekly Update',
    previewText: 'This week in tech...',
  },
});

Default Templates

Every new store is created with 6 default email templates:

KeyPurpose
order-notification-storeOrder notification to store admin
order-notification-profileOrder confirmation to profile
order-reminder-profileScheduled order item reminder to profile
contact-notification-storeContact form submission to store admin
subscription-confirmAudience double opt-in confirmation
newsletter-templateNewsletter email template