Email

Send transactional emails and manage campaigns

Overview

The Email resource lets you send transactional emails (receipts, password resets, notifications) and manage email campaigns. When your organization has a BYOK Resend API key configured, emails are sent from your own account and domain.

All email methods are available on r.email.

Transactional Email

Send an email

1const { data: result } = await r.email.send({
2 to: 'user@example.com',
3 subject: 'Your order has shipped',
4 html: '<h1>Order #1234</h1><p>Your package is on the way.</p>',
5});
6
7console.log(result.id); // Resend message ID
8console.log(result.status); // 'sent'

Parameters:

ParameterTypeRequiredDescription
tostring | string[]YesRecipient email(s).
subjectstringYesEmail subject line.
htmlstringNoHTML email body.
textstringNoPlain text email body.
fromstringNoSender address (defaults to org branded email).
reply_tostringNoReply-to address.

BYOK: Use your own email provider

Configure your own Resend API key in organization settings so emails come from your domain and your account:

1// Set your Resend API key (one-time setup)
2await r.organizationSettings.updateByok(orgId, {
3 resend_api_key: 're_your_resend_key',
4});
5
6// Now r.email.send() uses your Resend account
7await r.email.send({
8 to: 'customer@example.com',
9 from: 'team@yourdomain.com',
10 subject: 'Welcome to Our Platform',
11 html: '<h1>Welcome!</h1>',
12});

Campaigns

For bulk email marketing, use the campaign methods:

MethodDescription
listCampaigns()List all campaigns.
getCampaign(id)Get campaign details.
getCampaignStats(id)Get delivery statistics.
createCampaign(input)Create a draft campaign.
importRecipients(campaignId, input)Import recipient emails.
startCampaign(id)Start sending a campaign.
pauseCampaign(id)Pause a sending campaign.
resumeCampaign(id)Resume a paused campaign.
sendBatch(id)Trigger next manual send batch.
importSuppressions(input)Add to suppression list.