The batch validation header controls how emails are validated in batch sending. x-batch-validation Choose between strict and permissive mode.

Strict mode (default)

Strict mode sends the batch only if all emails in the batch request are valid.
  • Atomic behavior: if any email in the batch fails validation, the entire batch is rejected
  • Error details: only the validation error causing the failure is returned
If the header is omitted, strict mode applies.

Permissive mode

Permissive mode processes all emails, allowing for partial success and returns the following two arrays:
  • data: array of objects for all created emails, each containing an email id.
  • errors: array of objects for emails which could not be created due to validation errors. Each object contains the following properties:
    • index: index of the email in the batch request
    • message: error message identifying the validation error

How to use batch validation modes

import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, errors } = 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>',
    },
  ],
  {
    batchValidation: 'permissive',
  },
);

Example response

Response
{
  "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."
    }
  ]
}

Which errors are returned?

Only permissive mode returns an errors array, since the entire batch is rejected if any email fails validation in strict mode. When an email in your payload causes an error, that email cannot be created, so an error object is returned. Reasons your email may cause an error include:
  • Required fields are missing.
  • Fields contain invalid data.
  • The batch contains more than 100 emails.
Importantly, this means the following:
  • The email will not appear in the dashboard, since it could not be created.
  • The error object will be included in the errors array.
  • The only way to understand why the email failed is to inspect the returned error object.