Back to arky.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/businesses/{businessId}/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>',
fromName: 'My Store',
fromEmail: 'orders@mystore.com',
replyTo: 'support@mystore.com',
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
fromName required string Sender display name
fromEmail 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",
  "businessId": "biz_123",
  "subject": { "en": "Order #{{orderId}} confirmed" },
  "body": "<h1>Thank you!</h1><p>Your order #{{orderId}} has been confirmed.</p>",
  "fromName": "My Store",
  "fromEmail": "orders@mystore.com",
  "replyTo": "support@mystore.com",
  "preheader": "Your order is confirmed",
  "status": "ACTIVE",
  "createdAt": 1704067200,
  "updatedAt": 1704067200
}

Get Email Template

GET /v1/businesses/{businessId}/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/businesses/{businessId}/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
createdAtFrom optional number Filter by creation date (start)
createdAtTo optional number Filter by creation date (end)
limit optional number Items per page
cursor optional string Pagination cursor
sortField optional string Sort field
sortDirection optional asc | desc Sort direction

Update Email Template

PUT /v1/businesses/{businessId}/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
fromName optional string Updated sender name
fromEmail 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/businesses/{businessId}/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',
  businessId: 'biz_123',
  emailTemplateId: 'tmpl_abc123',
  audienceId: 'aud_newsletter', // send to all subscribers
  vars: {
    title: 'Weekly Update',
    previewText: 'This week in tech...',
  },
});

Default Templates

Every new business is created with 7 default email templates:

KeyPurpose
order-notification-businessOrder notification to business admin
order-notification-customerOrder confirmation to customer
booking-notification-businessBooking notification to business admin
booking-notification-customerBooking confirmation to customer
contact-notification-businessContact form submission to business admin
subscription-confirmAudience double opt-in confirmation
newsletter-templateNewsletter email template