Notification
Send emails to audiences or individual recipients using templates
The Notification module lets you send emails using email templates. Send to entire audiences (newsletters) or trigger individual notification emails.
Trigger Notification
/v1/notifications/trigger sdk.notification.trigger() Send an email using an email template. You can send to all subscribers of an audience, or to specific recipients. The storeId is passed in the body, not the URL.
// Send newsletter to all audience subscribers
await sdk.notification.trigger({
channel: 'email',
store_id: 'store_123',
email_template_id: 'tmpl_newsletter',
audience_id: 'aud_newsletter',
vars: {
title: 'Weekly Update',
content: 'Here is what happened this week...',
},
});
// Send to specific recipients
await sdk.notification.trigger({
channel: 'email',
store_id: 'store_123',
email_template_id: 'tmpl_welcome',
recipients: ['[email protected]'],
vars: {
name: 'John',
},
});Parameters
| Name | Type | Description |
|---|---|---|
channel required | string | Notification channel (currently 'email') |
store_id required | string | Store ID |
email_template_id required | string | Email template ID to render |
audience_id optional | string | Send to all subscribers of this audience |
recipients optional | string[] | Send to specific email addresses |
vars optional | Record<string, any> | Template variables passed to Handlebars |
Either audienceId or recipients should be provided. If audienceId is set, the email is sent to all active subscribers of that audience.
How Notifications Work
Notifications are typically triggered in two ways:
1. Via Workflows (Automated)
Default workflows automatically send notification emails when events occur:
- Order created -> sends order confirmation to profile + notification to store
- Service scheduled through an order -> uses the same order confirmation workflow
- Form submitted -> sends contact notification to store
These workflows call the notification trigger endpoint internally using the default email templates.
2. Via SDK (Manual)
Use sdk.notification.trigger() directly for:
- Sending newsletters to an audience
- Custom transactional emails
- One-off notifications
Template Variables
Variables are passed as the vars parameter and rendered using Handlebars syntax ({{variable}}) in the email template body and subject.
// Template body: "<h1>Hello {{name}}</h1><p>Your code: {{code}}</p>"
await sdk.notification.trigger({
channel: 'email',
store_id: 'store_123',
email_template_id: 'tmpl_custom',
recipients: ['[email protected]'],
vars: {
name: 'Jane',
code: 'ABC123',
},
});
See Email Templates for creating and managing templates.