Skip to main content
POST
/
emails
/
batch
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.batch.send([
  {
    from: 'Acme <onboarding@resend.dev>',
    to: ['foo@gmail.com'],
    subject: 'hello world',
    html: '<h1>it works!</h1>',
  },
  {
    from: 'Acme <onboarding@resend.dev>',
    to: ['bar@outlook.com'],
    subject: 'world hello',
    html: '<p>it works!</p>',
  },
]);
{
  "data": [
    {
      "id": "ae2014de-c168-4c61-8267-70d2662a1ce1"
    },
    {
      "id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb"
    }
  ],
  // the `errors` array is only present in permissive batch validation mode
  "errors": [
    {
      "index": 2, // 0-indexed (first item is index 0)
      "message": "The `to` field is missing."
    }
  ]
}
Instead of sending one email per HTTP request, we provide a batching endpoint that permits you to send up to 100 emails in a single API call.

Body Parameters

from
string
required
Sender email address.To include a friendly name, use the format "Your Name <sender@domain.com>".
to
string | string[]
required
Recipient email address. For multiple addresses, send as an array of strings. Max 50.
subject
string
required
Email subject.
bcc
string | string[]
Bcc recipient email address. For multiple addresses, send as an array of strings.
cc
string | string[]
Cc recipient email address. For multiple addresses, send as an array of strings.
html
string
The HTML version of the message.
text
string
The plain text version of the message.
If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string.
react
React.ReactNode
The React component used to write the message. Only available in the Node.js SDK.
headers
object
Custom headers to add to the email.
tags
array
Custom data passed in key/value pairs.See examples.
template
object
Templates API is currently in private beta and only available to a limited number of users.
To send using a template, provide a template object with:
  • id: id of the published template
  • variables: array of variable objects (if applicable)
If a template is provided, you cannot send html, text, or react in the payload, otherwise the API will return a validation error.When sending a template, the payload for from, subject, and reply_to take precedence over the template’s defaults for these fields. If the template does not provide a default value for these fields, you must provide them in the payload.
id
string
required
The id of the published email template. Required if template is provided. Only published templates can be used when sending emails.See the errors reference for more details.
variables
object
Template variables object with key/value pairs.
variables: {
	CTA: 'Sign up now',
	CTA_LINK: 'https://example.com/signup'
}
When sending the template, the HTML will be parsed. If all the variables used in the template were provided, the email will be sent. If not, the call will throw a validation error.See the errors reference for more details.See examples.

Headers

Idempotency-Key
string
Add an idempotency key to prevent duplicated emails.
  • Should be unique per API request
  • Idempotency keys expire after 24 hours
  • Have a maximum length of 256 characters
Learn more about idempotency keys →
x-batch-validation
strict | permissive
default:"strict"
Batch validation modes control how emails are validated in batch sending.Choose between two modes:
  • Strict mode (default): sends the batch only if all emails in the request are valid.
  • Permissive mode: processes all emails, allowing for partial success and returning validation errors if present.
Learn more about batch validation →

Limitations

The attachments and scheduled_at fields are not supported yet.
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.batch.send([
  {
    from: 'Acme <onboarding@resend.dev>',
    to: ['foo@gmail.com'],
    subject: 'hello world',
    html: '<h1>it works!</h1>',
  },
  {
    from: 'Acme <onboarding@resend.dev>',
    to: ['bar@outlook.com'],
    subject: 'world hello',
    html: '<p>it works!</p>',
  },
]);
{
  "data": [
    {
      "id": "ae2014de-c168-4c61-8267-70d2662a1ce1"
    },
    {
      "id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb"
    }
  ],
  // the `errors` array is only present in permissive batch validation mode
  "errors": [
    {
      "index": 2, // 0-indexed (first item is index 0)
      "message": "The `to` field is missing."
    }
  ]
}
I