Sending
POST /emails sends one email. The body takes from, to, subject and html or text, plus the optional fields below.
| Field | Notes |
|---|---|
to, cc, bcc | A string or an array. At most 50 addresses in total. |
reply_to | A string or an array. |
headers | An object of custom headers. Message-ID is ignored: the provider sets it. |
tags | An array of { "name": "...", "value": "..." }. |
attachments | See below. |
scheduled_at | See below. |
template | { "id": "...", "variables": { ... } } instead of html and text. See templates. |
Addresses may be ann@example.com or Ann <ann@example.com>. An invalid address answers 400 validation_error; a missing from, to or subject answers 422 missing_required_field.
Batch
POST /emails/batch takes an array of up to 100 email bodies and answers { "data": [{ "id": "..." }, ...] } in the same order.
await resend.batch.send([
{ from: 'Acme <hello@yourdomain.com>', to: ['ann@example.com'], subject: 'Hi Ann', html: '<p>Hi</p>' },
{ from: 'Acme <hello@yourdomain.com>', to: ['bob@example.com'], subject: 'Hi Bob', html: '<p>Hi</p>' },
]);
By default one invalid item refuses the whole batch and nothing is sent. Send the header x-batch-validation: permissive to send the valid items and get the rest back as { "data": [...], "errors": [{ "index": 1, "message": "..." }] }. scheduled_at is not supported in a batch (422).
Scheduling
Set scheduled_at to an ISO 8601 date (2026-12-25T09:00:00Z) or to in 10 minutes, in 2 hours or in 1 day. It must be in the future and within 30 days; anything else answers 400 validation_error. The email's last_event is scheduled until it is due. A job runs every minute and sends what is due.
PATCH /emails/:idwith{ "scheduled_at": "..." }changes the time of a scheduled email.POST /emails/:id/cancelcancels it. Only a scheduled email can be changed or cancelled.
Scheduled emails count toward your sending caps when they are sent, not when they are scheduled.
Idempotency
Send an Idempotency-Key header (1 to 256 characters) and a retry of the same request never sends twice, for 24 hours.
await resend.emails.send(payload, { idempotencyKey: 'order-1042-receipt' });
| Situation | Response |
|---|---|
| Same key, same body | The original response again, with the same status. Nothing is sent. |
| Same key, different body | 409 invalid_idempotent_request |
| Same key while the first request is still running | 409 concurrent_idempotent_requests |
| Key empty or longer than 256 characters | 400 invalid_idempotency_key |
On a batch the key covers the whole batch. A 5xx means the outcome is uncertain and it is safe to retry with the same key. A 409 concurrent_idempotent_requests after a timeout means the provider may already have accepted the message: wait and retry with the same key, never with a new one.
Attachments
await resend.emails.send({
from: 'Acme <hello@yourdomain.com>',
to: ['ann@example.com'],
subject: 'Your invoice',
text: 'Attached.',
attachments: [{ filename: 'invoice.pdf', content: pdfBuffer.toString('base64'), content_type: 'application/pdf' }],
});
Each attachment needs a filename and base64 content; content_type is optional. Set content_id to embed an image inline and reference it as cid:<content_id> in the HTML. Remote path attachments are not supported: a missing or non-base64 content answers 422 invalid_attachment. Read attachments back with GET /emails/:id/attachments; they are kept for 30 days.
Tags
Tags are returned on the email and in every webhook for it as an object ("tags": { "campaign": "welcome" }), so you can match events to your own records.
Test mode and test addresses
Two ways to try sending without mailing a real person.
Test mode. Add the header x-me-send-test: true (or use a key the operator marked as test-only). The request runs every check, is logged with "test": true, and is never handed to a delivery provider. Test sends do not count toward your caps, and test and live requests never share an idempotency record.
Test addresses. These recipients are simulated, never delivered, and produce the matching event, so you can exercise your webhook handlers from a live key:
| Address | Simulated outcome |
|---|---|
delivered@resend.dev | email.delivered |
bounced@resend.dev | email.bounced |
complained@resend.dev | email.complained |
suppressed@resend.dev | email.suppressed |
A label after a + works too (delivered+signup@resend.dev). The from domain must still be verified.
What happens to the message
Recipients on your suppression list are dropped before sending. If every recipient is suppressed the email is logged with last_event suppressed and nothing is sent. Recipients on a deny rule or at a known disposable-mail domain are refused with 422 validation_error.
Reading emails
GET /emails/:idreturns one email with its body,last_eventandscheduled_at.GET /emailslists emails, newest first, withlimit(1 to 100, default 20) and anafteremail id for the next page;has_moretells you whether there is one.GET /recipients/:address/emailslists every message sent to one address.POST /emails/:id/sharemakes a read-only link to one email that expires between 1 minute and 30 days (default 7 days), for showing a message to someone without a key.
last_event is one of queued, scheduled, canceled, sent, delivered, delivery_delayed, bounced, complained, failed, suppressed, opened or clicked. A late delivered never replaces opened or clicked.