> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendbaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Batch sending

> Send up to 1,000 emails or SMS in one request. Each item succeeds or fails on its own.

`POST /v1/emails/batch` and `POST /v1/sms/batch` accept up to 1,000 messages. Each item is validated and queued independently, so one bad address never rejects the other 999. The batch counts as one request against the [rate limit](https://docs.sendbaze.com/resources/rate-limits.md), which is why bulk sends should use it.

```ts Node.js theme={"dark"}
const { results } = await sendbaze.emails.batch([
  { from: "orders@yourshop.co.za", to: "a@example.com", subject: "Hi", text: "..." },
  { from: "orders@yourshop.co.za", to: "not-an-email", subject: "Hi", text: "..." },
]);

for (const result of results) {
  if (result.ok) console.log(result.data.id);
  else console.warn(result.index, result.error.code, result.error.fields);
}
```

```bash cURL theme={"dark"}
curl https://api.sendbaze.com/v1/emails/batch \
  -H "Authorization: Bearer $SENDBAZE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "emails": [
      { "from": "orders@yourshop.co.za", "to": "a@example.com", "subject": "Hi", "text": "..." },
      { "from": "orders@yourshop.co.za", "to": "not-an-email", "subject": "Hi", "text": "..." }
    ]
  }'
```

```json Response (200) theme={"dark"}
{
  "results": [
    { "index": 0, "ok": true, "data": { "id": "em_01j9...", "status": "queued", "mode": "live" } },
    {
      "index": 1,
      "ok": false,
      "error": { "code": "validation_error", "message": "The request has invalid fields.", "fields": { "to": ["must be a valid email address"] } }
    }
  ]
}
```

## Rules

* Results come back in input order with the item's `index`.
* The response is `200` even when some items fail. Check `ok` on each.
* `Idempotency-Key` applies to the whole batch, not to items. Use `tags` to reconcile items with your own records.
* Each item is paid for on its own: allowance first, then the wallet, then overage. Once nothing covers a send, the remaining items fail with `allowance_exhausted` (or `insufficient_credits` on pay as you go) and the earlier ones still go out.
* SMS batches debit credits per item; if credits run out part-way, the remaining items fail with `insufficient_credits` and the earlier ones still send.

> [!TIP]
>
> For a newsletter to thousands of people, send batches of 1,000 from a queue in your application, and set `"class": "marketing"` on every item so each email gets its unsubscribe headers.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.