Skip to main content
Wraps supports SES-native email templates. Templates are stored in AWS and referenced by name at send time. Use {{variable}} syntax to inject dynamic data.

Create a template

import { WrapsEmail } from '@wraps.dev/email';

const email = new WrapsEmail({ region: 'us-east-1' });

await email.templates.create({
  name: 'welcome',
  subject: 'Welcome {{name}}!',
  html: '<h1>Hello {{name}}</h1>',
});
Template variables use double-curly-brace syntax: {{variableName}}. Substitution happens on the AWS side at send time.

Send with a template

await email.sendTemplate({
  from: '[email protected]',
  to: '[email protected]',
  template: 'welcome',
  templateData: { name: 'Alice' },
});

Bulk send

Send to up to 50 recipients in a single API call, each with their own template data.
await email.sendBulkTemplate({
  from: '[email protected]',
  template: 'weekly-digest',
  destinations: [
    { to: '[email protected]', templateData: { name: 'Alice' } },
    { to: '[email protected]', templateData: { name: 'Bob' } },
  ],
});
SES bulk template sends are limited to 50 destinations per call. For larger lists, split into multiple sendBulkTemplate calls.

Template CRUD

// Retrieve a template
const template = await email.templates.get('welcome');

// List all templates
const templates = await email.templates.list();

// Update a template (pass only the fields you want to change)
await email.templates.update({
  name: 'welcome',
  subject: 'New subject',
});

// Delete a template
await email.templates.delete('welcome');

templates.create() parameters

name
string
required
Unique template name used to reference the template when sending.
subject
string
required
Subject line. Supports {{variable}} substitution.
html
string
HTML body. Supports {{variable}} substitution. Provide html or text (or both).
text
string
Plain text body. Supports {{variable}} substitution.

sendTemplate() parameters

from
string
required
Sender email address. Must be a SES-verified domain or address.
to
string | string[]
required
Recipient email address or array of addresses.
template
string
required
Name of the template to use (must already exist via templates.create()).
templateData
object
required
Key-value pairs used to replace {{variable}} placeholders in the template.
replyTo
string
Reply-to email address.
cc
string | string[]
CC recipients.
bcc
string | string[]
BCC recipients.

sendBulkTemplate() parameters

from
string
required
Sender email address. Must be a SES-verified domain or address.
template
string
required
Name of the template to use.
destinations
object[]
required
Array of up to 50 recipient objects.

templates.update() parameters

name
string
required
Name of the template to update.
subject
string
Updated subject line.
html
string
Updated HTML body.
text
string
Updated plain text body.

Build docs developers (and LLMs) love