Send batch emails
POST /emails/batch
Accepts a JSON array of transactional emails in one request and returns their assigned identifiers in matching order. Supports Idempotency-Key retries and the optional x-batch-validation header to choose strict all-or-nothing validation or permissive partial acceptance.
Send an API key as a bearer token in the Authorization header. A sending access key is enough, and a full access key works too.
| Name | Type | Required | Details |
|---|---|---|---|
Idempotency-Key |
string | No | Send a unique value to make a retry safe: for a day, a repeat of this request answers with the original outcome. |
A JSON array of object.
| Field | Type | Required | Details |
|---|---|---|---|
[].template |
any | No | |
[].topic_id |
any | No | |
[].from |
string | Yes | |
[].to |
string or array of string | Yes | |
[].subject |
string | Yes | |
[].bcc |
string or array of string | No | |
[].cc |
string or array of string | No | |
[].reply_to |
string or array of string | No | |
[].html |
string | No | |
[].text |
string | No | |
[].headers |
object | No | |
[].scheduled_at |
string | No | |
[].attachments |
array of object | No | |
[].attachments[].content |
string or array of integer | No | 0 to 255. |
[].attachments[].path |
string | No | |
[].attachments[].filename |
string | No | |
[].attachments[].content_type |
string | No | |
[].attachments[].content_id |
string | No | |
[].tags |
array of object | No | |
[].tags[].name |
string | Yes | |
[].tags[].value |
string | Yes |
Status 200, a JSON object.
| Field | Type | Details |
|---|---|---|
data |
array of object | |
data[].id |
string | Format uuid. Matches ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$. |
errors |
array of object | |
errors[].index |
integer | 0 to 9007199254740991. |
errors[].message |
string |
Headers: x-request-id, ratelimit-limit, ratelimit-remaining, ratelimit-reset, x-hermesmail-monthly-quota, x-hermesmail-daily-quota, idempotent-replayed.
Each error answers with the status below and a JSON body naming the error. Every error has its own entry.
Error headers: x-request-id, ratelimit-limit, ratelimit-remaining, ratelimit-reset, retry-after.
curl -X POST 'https://api.hermesmail.app/emails/batch' \
-H "Authorization: Bearer $HERMESMAIL_API_KEY" \
-H 'Content-Type: application/json' \
-d '[
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
},
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
}
]'
import { Resend } from 'resend';
const resend = new Resend(process.env.HERMESMAIL_API_KEY, { baseUrl: 'https://api.hermesmail.app' });
const { data, error } = await resend.batch.send([
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
},
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
}
]);
import os
import resend
resend.api_key = os.environ["HERMESMAIL_API_KEY"]
resend.api_url = "https://api.hermesmail.app"
result = resend.Batch.send([
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
},
{
"from": "Sample sender <[email protected]>",
"to": [
"[email protected]"
],
"subject": "A sample subject",
"html": "<p>The message body, in HTML.</p>",
"text": "The message body, in plain text."
}
])
<?php
// Set RESEND_BASE_URL="https://api.hermesmail.app" in the environment.
$resend = Resend::client(getenv("HERMESMAIL_API_KEY"));
$result = $resend->batch->send([
[
"from" => "Sample sender <[email protected]>",
"to" => [
"[email protected]"
],
"subject" => "A sample subject",
"html" => "<p>The message body, in HTML.</p>",
"text" => "The message body, in plain text."
],
[
"from" => "Sample sender <[email protected]>",
"to" => [
"[email protected]"
],
"subject" => "A sample subject",
"html" => "<p>The message body, in HTML.</p>",
"text" => "The message body, in plain text."
]
]);
package main
import (
"net/url"
"os"
"github.com/resend/resend-go/v4"
)
func main() {
client := resend.NewClient(os.Getenv("HERMESMAIL_API_KEY"))
baseURL, _ := url.Parse("https://api.hermesmail.app/")
client.BaseURL = baseURL
_, err := client.Batch.Send([]*resend.SendEmailRequest{
&resend.SendEmailRequest{
From: "Sample sender <[email protected]>",
To: []string{"[email protected]"},
Subject: "A sample subject",
Html: "<p>The message body, in HTML.</p>",
Text: "The message body, in plain text.",
},
&resend.SendEmailRequest{
From: "Sample sender <[email protected]>",
To: []string{"[email protected]"},
Subject: "A sample subject",
Html: "<p>The message body, in HTML.</p>",
Text: "The message body, in plain text.",
},
})
_ = err
}
# Set RESEND_BASE_URL="https://api.hermesmail.app/" before require "resend".
require "resend"
Resend.api_key = ENV.fetch("HERMESMAIL_API_KEY")
result = Resend::Batch.send([
{
"from" => "Sample sender <[email protected]>",
"to" => [
"[email protected]"
],
"subject" => "A sample subject",
"html" => "<p>The message body, in HTML.</p>",
"text" => "The message body, in plain text."
},
{
"from" => "Sample sender <[email protected]>",
"to" => [
"[email protected]"
],
"subject" => "A sample subject",
"html" => "<p>The message body, in HTML.</p>",
"text" => "The message body, in plain text."
}
])