Templates
Store an email once and send it by id. Templates hold a subject, html, and an optional plain-text alternative; {{TOKEN}} merge tags are replaced by the variables you pass at send time. Unknown tokens are left visible instead of silently sending blanks. Mistakes should be seen, not delivered. Every new workspace starts with three editable starters (welcome, password reset, receipt).
For the product overview, read the email templates guide.
Create a template
POST/api/v1/templates
const { template } = await notice.templates.create({
name: "Welcome",
subject: "Welcome to {{PRODUCT_NAME}}, {{FIRST_NAME}}",
html: "<p>Hi {{FIRST_NAME}}, your account is live.</p>",
});| Field | Type | Description |
|---|---|---|
namerequired | string | Unique per workspace. Used in the dashboard. |
subjectrequired | string | May contain {{TOKEN}} merge tags. |
htmlrequired | string | HTML body, up to 1MB. |
text | string | null | Optional plain-text alternative. |
Send with a template
POST/api/v1/email/send
Pass templateId instead of content. Anything you do provide (subject, html, text) overrides that part of the template. Works in batch sends too; a batch that reuses one template only loads it once.
await notice.emails.send({
from: "Acme <[email protected]>",
to: "[email protected]",
templateId: template.id,
variables: { PRODUCT_NAME: "Acme", FIRST_NAME: "Sam" },
});| Field | Type | Description |
|---|---|---|
templateId | string | Id of a stored template. |
variables | object | Up to 50 string values for {{TOKEN}} tags. Also works on direct sends without a template. |
Manage templates
GET/api/v1/templates
PATCH/api/v1/templates/:id
DELETE/api/v1/templates/:id
The dashboard's template editor includes a live preview with sample variables; edit on the left, see the rendered email on the right.