Send Batch Emails
Trigger up to 100 batch emails at once.
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>',
},
]);
$resend = Resend::client('re_xxxxxxxxx');
$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>',
]
]);
import resend
from typing import List
resend.api_key = "re_xxxxxxxxx"
params: List[resend.Emails.SendParams] = [
{
"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>",
}
]
resend.Batch.send(params)
require "resend"
Resend.api_key = 're_xxxxxxxxx'
params = [
{
"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>",
}
]
Resend::Batch.send(params)
package main
import (
"context"
"fmt"
"github.com/resend/resend-go/v4"
)
func main() {
ctx := context.TODO()
client := resend.NewClient("re_xxxxxxxxx")
var batchEmails = []*resend.SendEmailRequest{
{
From: "Acme <onboarding@resend.dev>",
To: []string{"foo@gmail.com"},
Subject: "hello world",
Html: "<h1>it works!</h1>",
},
{
From: "Acme <onboarding@resend.dev>",
To: []string{"bar@outlook.com"},
Subject: "world hello",
Html: "<p>it works!</p>",
},
}
sent, err := client.Batch.SendWithContext(ctx, batchEmails)
if err != nil {
panic(err)
}
fmt.Println(sent.Data)
}
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::{Resend, Result};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let emails = vec![
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["foo@gmail.com"],
"hello world",
)
.with_html("<h1>it works!</h1>"),
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["bar@outlook.com"],
"world hello",
)
.with_html("<p>it works!</p>"),
];
let _emails = resend.batch.send(emails).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.batch.model.CreateBatchEmailsResponse;
import com.resend.services.emails.model.CreateEmailOptions;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
CreateEmailOptions firstEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("foo@gmail.com")
.subject("hello world")
.html("<h1>it works!</h1>")
.build();
CreateEmailOptions secondEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("bar@outlook.com")
.subject("world hello")
.html("<p>it works!</p>")
.build();
CreateBatchEmailsResponse data = resend.batch().send(
Arrays.asList(firstEmail, secondEmail)
);
}
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var mail1 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "foo@gmail.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var mail2 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "bar@outlook.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var resp = await resend.EmailBatchAsync( [ mail1, mail2 ] );
Console.WriteLine( "Nr Emails={0}", resp.Content.Count );
curl -X POST 'https://api.resend.com/emails/batch' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d $'[
{
"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>"
}
]'
resend emails batch --file ./path/to/emails.json
{
"data": [
{
"id": "ae2014de-c168-4c61-8267-70d2662a1ce1"
},
{
"id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb"
}
]
}
Instead of sending one email per HTTP request, Resend provides a batching endpoint that permits you to send up to 100 emails in a single API call.
Body Parameters
Sender email address.To include a friendly name, pass the sender as
Name <email@example.com>, for example Acme <onboarding@example.dev>.Recipient email address. For multiple addresses, send as an array of strings.
Max 50.
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.
Custom data passed in key/value pairs.See examples.
Hide properties
Hide properties
The name of the email tag.It can only contain ASCII letters (a–z, A–Z), numbers (0–9), underscores (_), or dashes (-).It can contain no more than 256 characters.
To send using a template, provide a
template object with:id: the id or the alias of the published templatevariables: an object with a key for each variable (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.The id of the published email template. Required if
template is provided. Only published templates can be used when sending emails.Template variables object with key/value pairs.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 or learn more about templates.
variables: {
CTA: 'Sign up now',
CTA_LINK: 'https://example.com/signup'
}
Hide properties
Hide properties
The key of the variable.May only contain ASCII letters (a–z, A–Z), numbers (0–9), and underscores (_). The following variable names are reserved and cannot be used:
FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL.It can contain no more than 50 characters.Headers
Add an idempotency key to prevent duplicated emails.
- Must be unique per API request
- Idempotency keys expire after 24 hours
- Have a maximum length of 256 characters
Limitations
Theattachments field isn’t supported yet.
Response format
When the request succeeds, each entry indata corresponds to the email at the same index in the batch payload (0-based). The first email in your request will be the first entry in data, and so on.
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>',
},
]);
$resend = Resend::client('re_xxxxxxxxx');
$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>',
]
]);
import resend
from typing import List
resend.api_key = "re_xxxxxxxxx"
params: List[resend.Emails.SendParams] = [
{
"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>",
}
]
resend.Batch.send(params)
require "resend"
Resend.api_key = 're_xxxxxxxxx'
params = [
{
"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>",
}
]
Resend::Batch.send(params)
package main
import (
"context"
"fmt"
"github.com/resend/resend-go/v4"
)
func main() {
ctx := context.TODO()
client := resend.NewClient("re_xxxxxxxxx")
var batchEmails = []*resend.SendEmailRequest{
{
From: "Acme <onboarding@resend.dev>",
To: []string{"foo@gmail.com"},
Subject: "hello world",
Html: "<h1>it works!</h1>",
},
{
From: "Acme <onboarding@resend.dev>",
To: []string{"bar@outlook.com"},
Subject: "world hello",
Html: "<p>it works!</p>",
},
}
sent, err := client.Batch.SendWithContext(ctx, batchEmails)
if err != nil {
panic(err)
}
fmt.Println(sent.Data)
}
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::{Resend, Result};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let emails = vec![
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["foo@gmail.com"],
"hello world",
)
.with_html("<h1>it works!</h1>"),
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["bar@outlook.com"],
"world hello",
)
.with_html("<p>it works!</p>"),
];
let _emails = resend.batch.send(emails).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.batch.model.CreateBatchEmailsResponse;
import com.resend.services.emails.model.CreateEmailOptions;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
CreateEmailOptions firstEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("foo@gmail.com")
.subject("hello world")
.html("<h1>it works!</h1>")
.build();
CreateEmailOptions secondEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("bar@outlook.com")
.subject("world hello")
.html("<p>it works!</p>")
.build();
CreateBatchEmailsResponse data = resend.batch().send(
Arrays.asList(firstEmail, secondEmail)
);
}
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var mail1 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "foo@gmail.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var mail2 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "bar@outlook.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var resp = await resend.EmailBatchAsync( [ mail1, mail2 ] );
Console.WriteLine( "Nr Emails={0}", resp.Content.Count );
curl -X POST 'https://api.resend.com/emails/batch' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d $'[
{
"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>"
}
]'
resend emails batch --file ./path/to/emails.json
{
"data": [
{
"id": "ae2014de-c168-4c61-8267-70d2662a1ce1"
},
{
"id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb"
}
]
}
Was this page helpful?
⌘I
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>',
},
]);
$resend = Resend::client('re_xxxxxxxxx');
$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>',
]
]);
import resend
from typing import List
resend.api_key = "re_xxxxxxxxx"
params: List[resend.Emails.SendParams] = [
{
"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>",
}
]
resend.Batch.send(params)
require "resend"
Resend.api_key = 're_xxxxxxxxx'
params = [
{
"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>",
}
]
Resend::Batch.send(params)
package main
import (
"context"
"fmt"
"github.com/resend/resend-go/v4"
)
func main() {
ctx := context.TODO()
client := resend.NewClient("re_xxxxxxxxx")
var batchEmails = []*resend.SendEmailRequest{
{
From: "Acme <onboarding@resend.dev>",
To: []string{"foo@gmail.com"},
Subject: "hello world",
Html: "<h1>it works!</h1>",
},
{
From: "Acme <onboarding@resend.dev>",
To: []string{"bar@outlook.com"},
Subject: "world hello",
Html: "<p>it works!</p>",
},
}
sent, err := client.Batch.SendWithContext(ctx, batchEmails)
if err != nil {
panic(err)
}
fmt.Println(sent.Data)
}
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::{Resend, Result};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let emails = vec![
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["foo@gmail.com"],
"hello world",
)
.with_html("<h1>it works!</h1>"),
CreateEmailBaseOptions::new(
"Acme <onboarding@resend.dev>",
vec!["bar@outlook.com"],
"world hello",
)
.with_html("<p>it works!</p>"),
];
let _emails = resend.batch.send(emails).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.batch.model.CreateBatchEmailsResponse;
import com.resend.services.emails.model.CreateEmailOptions;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
CreateEmailOptions firstEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("foo@gmail.com")
.subject("hello world")
.html("<h1>it works!</h1>")
.build();
CreateEmailOptions secondEmail = CreateEmailOptions.builder()
.from("Acme <onboarding@resend.dev>")
.to("bar@outlook.com")
.subject("world hello")
.html("<p>it works!</p>")
.build();
CreateBatchEmailsResponse data = resend.batch().send(
Arrays.asList(firstEmail, secondEmail)
);
}
}
using Resend;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI
var mail1 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "foo@gmail.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var mail2 = new EmailMessage()
{
From = "Acme <onboarding@resend.dev>",
To = "bar@outlook.com",
Subject = "hello world",
HtmlBody = "<p>it works!</p>",
};
var resp = await resend.EmailBatchAsync( [ mail1, mail2 ] );
Console.WriteLine( "Nr Emails={0}", resp.Content.Count );
curl -X POST 'https://api.resend.com/emails/batch' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d $'[
{
"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>"
}
]'
resend emails batch --file ./path/to/emails.json
{
"data": [
{
"id": "ae2014de-c168-4c61-8267-70d2662a1ce1"
},
{
"id": "faccb7a5-8a28-4e9a-ac64-8da1cc3bc1cb"
}
]
}