Sending email
Transactional email with the smartletter SDK (or the Resend SDK): batches, scheduling, attachments.
The /emails endpoints follow Resend's API. The smartletter package is the official SDK: same method names as Resend (emails.send, batch.send, emails.get, emails.list, emails.update and emails.cancel), same { data, error } answer. The from domain must be verified in your workspace.
// npm i smartletter
import { Smartletter } from "smartletter";
const sl = new Smartletter(process.env.SMARTLETTER_API_KEY);
const { data, error } = await sl.emails.send({
from: "Acme <[email protected]>",
to: ["[email protected]"],
subject: "Welcome",
html: "<p>Hi Jane</p>",
});Already using the Resend SDK?
Keep your code: point the official Resend SDK at https://api.smartletter.ai with a Smartletter key.
import { Resend } from "resend";
// The official Resend SDK, pointed at Smartletter.
const resend = new Resend(process.env.SMARTLETTER_API_KEY, { baseUrl: "https://api.smartletter.ai" });
const { data, error } = await resend.emails.send({
from: "Acme <[email protected]>",
to: ["[email protected]"],
subject: "Welcome",
html: "<p>Hi Jane</p>",
});Batches
- Up to 100 emails per
POST /emails/batchcall, each with up to 50 recipients. The answer lists the ids in the order of the request. - One
Idempotency-Keycovers the whole batch, and the monthly quota is checked for the whole batch before anything is sent. - The first 20 recipients leave during the call. The rest leaves within a minute, paced so a batch never bursts past the sending rate. A temporary Amazon SES error is retried for you instead of failing.
x-batch-validation: strict(default) refuses the whole batch when one email is invalid;permissivesends the valid ones and lists the others inerrors(index,message). With the SDK:sl.batch.send(emails, { batchValidation: "permissive" }).- Attachments are not accepted in batches (as with Resend): send those emails one by one.
Scheduling
scheduled_attakes an ISO 8601 date (2026-10-20T09:00:00Z) or English likein 1 hour,tomorrow at 9am,Friday at 3pm ET(UTC when no time zone is given), up to 30 days ahead.- The email goes out within a minute of that time. Until then
last_eventisscheduled; move it withPATCH /emails/{id}or cancel it for good withPOST /emails/{id}/cancel. - When it leaves, everything is checked again: verified domain, suppression list and monthly quota. A scheduled email counts in the month it is sent.
- Webhooks:
email.scheduledwhen you schedule it, then the usual events once it is sent.
Topics
- With
topic_id, only the recipients eligible to that topic receive the email. The others are kept assuppressed(reason: topic_unsubscribed). - With an
opt_intopic, an address that is not a contact of the topic's segment is suppressed too. With adefault_ontopic, an address that is no contact still receives it. - A scheduled email is checked again when it really goes out: someone who left the topic meanwhile gets nothing. If the topic was archived meanwhile, nothing is sent.
Attachments
- Each file has
content(base64; a NodeBufferworks with the SDK) orpath(anhttpsURL we download, 10 seconds max, private addresses refused; up to 5 redirects are followed, each target held to the same rules). A file served asapplication/octet-streamtakes its type from its file name, unless you setcontent_type. filenameis required withcontent;content_typecomes from the file name when absent.content_idmakes the file an inline image: write<img src="cid:logo">in your html.- Up to 20 files and 10 MB in total per email (Resend allows 40 MB).
- Executable types are refused, as Amazon SES does:
.ade,.adp,.app,.asp,.bas,.bat,.cer,.chm,.cmd,.com,.cpl,.crt… - Files of a scheduled email are kept in private storage until it is sent or canceled, then deleted. They cannot be downloaded back.
Differences with Resend
- Not available yet:
GET /emails/{id}/attachments. GET /emails/{id}addsstatus,recipients(each recipient's status, with the SMTP diagnostic of a bounce or a delay) andattachments(name, type, size).- Opens and clicks are not tracked on transactional emails.