Skip to navigation

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

const { data: result } = await r.email.send({
to: 'user@example.com',
subject: 'Your order has shipped',
html: '<h1>Order #1234</h1><p>Your package is on the way.</p>',
});
console.log(result.id); // Resend message ID
console.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:

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

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.