Sending
Batch sending
Send up to 100 different emails in one request.
NeedsTier 1: IndividualNIN or BVN verified. Send from your domain or a sender handle to anyone.
Each item is a full email with its own recipients and body. Batches can't have attachments or scheduled_at.
const orders = [
{ no: "1042", email: "ada@example.com" },
{ no: "1043", email: "chidi@example.com" },
];
const { data } = await pm.emails.batch(
orders.map((o) => ({
from: "Acme Store <hello@acme.ng>",
to: o.email,
subject: `Your receipt #${o.no}`,
html: `<p>Thanks for order #${o.no}.</p>`,
})),
);
// data[i].id matches orders[i]When an item is invalid
By default the whole batch is checked first, and one invalid item fails it with 400. The error's errors array lists each problem with the item's index:
try {
await pm.emails.batch(emails);
} catch (err) {
if (err instanceof PadiMailError) for (const e of err.errors ?? []) console.log(`#${e.index}: ${e.code}`);
}To send the valid items and report the rest, pass validation: "permissive". The response then has data for what was sent and errors for what wasn't:
const { data, errors } = await pm.emails.batch(emails, { validation: "permissive" });curl -X POST "https://api.padimail.app/v1/emails/batch?validation=permissive" ...Items over a sending limit wait like any other email: their entries carry status: "deferred" and deferred_until.
Was this page helpful?