Sends up to 100 transactional emails. Body is a JSON array of the same objects as [Send Email](/docs/api-reference/v2/emails-send). Permission: `emails`.

## Body Parameters

Each array item:

| Name | Type | Description |
| ---- | ---- | ----------- |
| `from` | string | **Required.** Sender. Display name is allowed. Domain must be verified. |
| `to` | string or `[string]` | **Required.** One recipient. A one-address array is accepted. |
| `subject` | string | **Required.** Subject line. |
| `html` | string | HTML body. Provide exactly one of `html`, `tiptap`, or `markdown`. |
| `tiptap` | string or object | TipTap JSON. Rendered to HTML on send. |
| `markdown` | string | Markdown body. Rendered to HTML on send. |
| `text` | string | Plain-text body. Omit to generate from HTML. |
| `reply_to` | string or string[] | Reply-To addresses. |
| `cc` | string or string[] | Carbon copies. |
| `bcc` | string or string[] | Blind carbon copies. |
| `headers` | object | Extra MIME headers. |
| `tags` | `{ name, value }[]` | Metadata tags stored on the email. |
| `preview` | string | Preview / preheader text. |

## Options

| Name | Type | Description |
| ---- | ---- | ----------- |
| `Idempotency-Key` | string | Optional header. Suffixed with `:index` per item. SDK: pass `{ idempotencyKey }` as the second argument to `emails.batch`. |

## Response Fields

| Field | Type | Description |
| ----- | ---- | ----------- |
| `data` | `{ id }[]` | Queued email ids, same order as the request. |

## Errors

| Status | `name` | When |
| ------ | ------ | ---- |
| 401 | `missing_api_key` | Missing or invalid bearer token |
| 403 | `missing_permission` | Token lacks the `emails` permission |
| 422 | `validation_error` | Body is not an array, or an item fails send validation |

## Related

- [Send Email](/docs/api-reference/v2/emails-send)
- [Get Email](/docs/api-reference/v2/emails-get)
- [SDK: lumail.emails.batch](/docs/sdk/v2/emails-batch)


## API Reference
**Method:** POST
**Endpoint:** /api/v2/emails/batch

### SDK
```ts
import { Lumail } from "lumail";

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.emails.batch([
  {
    from: "hello@yourdomain.com",
    to: "a@example.com",
    subject: "A",
    html: "<p>A</p>",
  },
  {
    from: "hello@yourdomain.com",
    to: "b@example.com",
    subject: "B",
    html: "<p>B</p>",
  },
]);
if (error) {
  throw error;
}
console.log(data.data.map((email) => email.id));
```

### cURL
```bash
curl -X POST https://lumail.io/api/v2/emails/batch \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[
    {"from":"hello@yourdomain.com","to":"a@example.com","subject":"A","html":"<p>A</p>"},
    {"from":"hello@yourdomain.com","to":"b@example.com","subject":"B","html":"<p>B</p>"}
  ]'
```

### JavaScript
```javascript
const response = await fetch("https://lumail.io/api/v2/emails/batch", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify([
    {
      from: "hello@yourdomain.com",
      to: "a@example.com",
      subject: "A",
      html: "<p>A</p>",
    },
    {
      from: "hello@yourdomain.com",
      to: "b@example.com",
      subject: "B",
      html: "<p>B</p>",
    },
  ]),
});
const data = await response.json();
```

### Success Response
```json
{
  "data": [
    { "id": "eml_abc123def456" },
    { "id": "eml_def456abc123" }
  ]
}
```

### Error Response
```json
{
  "name": "validation_error",
  "message": "Batch payload must be an array of emails",
  "statusCode": 422
}
```
