Skip to main content
The Resend Go SDK allows you to send multiple emails in a single batch request with support for strict or permissive validation modes.

Quick Start

Here’s how to send a batch of emails:

Batch Send Methods

The SDK provides three methods for sending batch emails:
Source: batch.go:73

Batch Validation Modes

The SDK supports two validation modes for batch email sending:

Strict Mode (Default)

In strict mode, the entire batch fails if any email has validation errors:
Source: batch.go:13
Use strict mode when all emails in the batch must be sent together (all-or-nothing behavior).

Permissive Mode

In permissive mode, valid emails are sent even if some emails in the batch have errors:
Source: examples/send_batch_email.go:53
Use permissive mode when you want partial success - valid emails will be sent regardless of invalid ones in the batch.
Source: batch.go:16

BatchSendEmailOptions

The BatchSendEmailOptions struct supports the following fields:
string
Unique key to prevent duplicate batch sends. Valid for 24 hours.
BatchValidationMode
Validation mode: BatchValidationStrict (default) or BatchValidationPermissive.
  • Strict: All emails must be valid or entire batch fails
  • Permissive: Valid emails are sent, invalid ones are reported in errors
Source: batch.go:29

BatchEmailResponse

The response from a batch send includes:
[]SendEmailResponse
Array of successfully sent emails with their IDs.
[]BatchError
Array of errors for emails that failed validation (only in permissive mode).
Source: batch.go:58

Handling BatchErrors

In permissive mode, failed emails are reported in the Errors field:

BatchError Struct

int
Zero-based index of the failed email in the original batch array.
string
Error message describing why the email failed validation.
Source: batch.go:51

Using Idempotency Keys

Prevent duplicate batch sends with idempotency keys:
Source: examples/send_batch_email.go:42
Idempotency keys are valid for 24 hours. After that, the same key can be reused.

Common Use Cases

Processing Large Batches

For large email lists, split them into smaller batches:
Recommended batch size: 100-500 emails per request for optimal performance.

Error Handling

Handle both request errors and validation errors:

Best Practices

1

Choose the Right Validation Mode

Use strict mode for critical transactional emails where consistency matters:
2

Use Idempotency Keys

Always use idempotency keys for batch sends to prevent duplicates on retry:
3

Add Tags for Tracking

Tag batch emails for better analytics and debugging:
4

Handle Partial Failures

In permissive mode, always check and log validation errors:
5

Batch Size Optimization

Keep batches to 100-500 emails for optimal performance:
6

Rate Limit Awareness

Add delays between batches if sending many batches in succession:

Validation Mode Comparison

Source: batch.go:9

Next Steps

Sending Emails

Learn single email sending basics

Email Templates

Use templates in batch emails

Scheduled Emails

Schedule batch emails for later

Attachments

Add attachments to batch emails