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

# Send in batches

> Hand Kapso up to 100 messages per request. Kapso queues them and sends them as fast as your number allows.

WhatsApp only accepts so many messages per second from one number. If you send faster than that, it rejects the extra ones.

With batch send you don't have to pace anything. You give Kapso the messages, Kapso answers right away, and then sends them one after another at the speed your number can handle. You find out what happened to each message through webhooks.

Use it when your system produces many individual messages, like payment reminders, order updates or notifications, each one for a specific person and event.

For a campaign to a list of contacts, use a [broadcast](https://docs.kapso.ai/docs/platform/broadcasts/overview.md). For a single message that should go out right now, use the [regular send](https://docs.kapso.ai/docs/whatsapp/send-messages/text.md).

## Send a batch

Put your messages in a `messages` array. Each one looks exactly like a regular send. They don't have to share a template, and the same phone number can appear more than once.

```bash REST API icon="code" theme={null}
curl -X POST 'https://api.kapso.ai/meta/whatsapp/v24.0/647015955153740/messages/batch' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: reminders-2026-12-03-0001' \
  -d '{
    "messages": [
      {
        "messaging_product": "whatsapp",
        "to": "15551234567",
        "type": "template",
        "template": { "name": "payment_reminder", "language": { "code": "en_US" } },
        "biz_opaque_callback_data": "invoice-123"
      },
      {
        "messaging_product": "whatsapp",
        "to": "15557654321",
        "type": "template",
        "template": { "name": "payment_reminder", "language": { "code": "en_US" } },
        "biz_opaque_callback_data": "invoice-124"
      }
    ]
  }'
```

Two things in this request are optional, and you will want both:

* `Idempotency-Key` protects you from sending a batch twice. So does an identifier per message. See [retries](#if-your-request-fails-send-it-again).
* `biz_opaque_callback_data` is your own name for the message. See [follow each message](#follow-each-message).

You can send up to 100 messages per request. A batch counts as one request toward your [rate limit](https://docs.kapso.ai/api/rate-limits.md).

## What you get back

Kapso answers immediately with one line per message, in the same order you sent them:

```json theme={null}
{
  "messages": [
    { "index": 0, "id": "0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40", "status": "queued" },
    { "index": 1, "id": "7c1a44b2-91de-4c0b-8f35-2e6d7a9b0c13", "status": "queued" }
  ]
}
```

`queued` means Kapso has the message and will send it. Nothing has gone to WhatsApp yet.

If one message is malformed, only that message is refused. The rest are still queued:

```json theme={null}
{
  "messages": [
    { "index": 0, "id": "0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40", "status": "queued" },
    { "index": 1, "error": { "code": "invalid_payload", "message": "recipient phone number or BSUID missing" } }
  ]
}
```

The response is `202` either way, so check every line.

At this point Kapso has only checked that each message is well formed. Whether the template exists, whether the contact opted out, and whether you have enough balance are checked later, when the message is actually sent.

## Follow each message

Give each message your own reference in `biz_opaque_callback_data`, for example your invoice or order id. Kapso and WhatsApp send it back with every update about that message, so you always know which one it is.

There are two possible endings for a queued message.

**It was sent.** You get the same [message events](https://docs.kapso.ai/docs/platform/webhooks/message-events.md) as for any other send: `whatsapp.message.sent`, then `delivered` and `read`, or `failed`. Your reference is inside `message.kapso`:

```json theme={null}
{
  "message": {
    "id": "wamid.HBgNMTU1NTEyMzQ1NjcVAgARGBI2RDhDNjY5",
    "type": "template",
    "to": "15551234567",
    "kapso": {
      "direction": "outbound",
      "status": "sent",
      "queued_message_id": "0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40",
      "biz_opaque_callback_data": "invoice-123"
    }
  },
  "phone_number_id": "647015955153740"
}
```

**It was not sent.** You get `whatsapp.message.not_sent` with the reason. In almost every case the message never reached WhatsApp. The one exception is `send_outcome_unknown`, where it may have been delivered, so check `retryable` before you send it again. Add this event to your phone-number webhook:

```json theme={null}
{
  "message": {
    "id": "7c1a44b2-91de-4c0b-8f35-2e6d7a9b0c13",
    "biz_opaque_callback_data": "invoice-124",
    "to": "15557654321",
    "status": "not_sent",
    "reason": "meta_rejected",
    "retryable": true,
    "error": {
      "code": 132001,
      "message": "Template name does not exist in the translation"
    },
    "queued_at": "2026-12-03T18:00:02Z",
    "failed_at": "2026-12-03T18:07:42Z"
  },
  "phone_number_id": "647015955153740"
}
```

Every message ends with one of these two, so you never have to poll.

If you don't set `biz_opaque_callback_data`, Kapso fills it with the `id` from the response.

## Why a message is not sent

| `reason` | What happened | What to do |
| - | - | - |
| `meta_rejected` | WhatsApp refused it. `error.code` is WhatsApp's error code. | Fix the cause, then send it again |
| `expired` | It waited more than 4 hours | Send it again |
| `cancelled` | The queue was cleared | Send it again |
| `send_outcome_unknown` | Kapso lost contact with WhatsApp mid-send and can't tell if it arrived | Don't resend blindly. It may have been delivered |
| Anything else | A Kapso check stopped it, like an opt-out or a closed 24-hour window | Read `error.message` |

`retryable` is `false` only for `send_outcome_unknown`. In every other case the message did not reach WhatsApp, so sending it again cannot produce a duplicate.

## If your request fails, send it again

Networks drop. If you don't get a response, you can't know whether Kapso received the batch. There are two ways to retry without sending anything twice.

**Resend the same request.** Send an `Idempotency-Key` header with every request, using a value you make up and never reuse. If you have to retry, send the exact same request with the same key. Kapso recognizes it, returns the original response, and queues nothing a second time.

* The body has to be identical. The same key with a different body is rejected with `409`.
* Kapso remembers a key for at least 24 hours.

**Give each message an identifier.** Put your own unique id for the message in `kapso.identifier`:

```json theme={null}
{
  "messaging_product": "whatsapp",
  "to": "15551234567",
  "type": "template",
  "template": { "name": "payment_reminder", "language": { "code": "en_US" } },
  "kapso": { "identifier": "msg-98231" }
}
```

You can then retry those messages in any batch, mixed with new ones. For a message Kapso already has, it sends nothing and returns the original, marked as a duplicate:

```json theme={null}
{ "index": 0, "id": "0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40", "status": "sent", "duplicate": true }
```

* `id` and `status` are those of the original message, as it is right now. A repeat is never an error.
* Kapso remembers an identifier for at least 24 hours.
* Only the identifier is compared. If you reuse one with different content, you get the original back.
* To send again a message that was not sent, use a new identifier.

`id` is Kapso's id for the message. `kapso.identifier` is yours.

Use the header if you always retry a batch exactly as it was. Use identifiers if your system rebuilds batches. Without either, a request that goes through twice sends its messages twice.

## How Kapso sends the queue

* **In the order you sent them.** A contact never gets two of your messages out of order.
* **One at a time per contact.** Messages to the same contact go out one after the other, each once the previous one has been sent. Several messages to one phone take longer than the same number of messages to different phones.
* **At your number's speed.** 60 messages per second by default. If WhatsApp slows your number down, Kapso waits and continues on its own. Contact support if your number supports a higher rate.
* **Only once.** Kapso never sends the same queued message to WhatsApp twice.
* **Within 4 hours.** Anything still waiting after that is dropped and reported as `expired`.

Messages wait in line. A message added behind a large batch goes out after it, so use the [regular send](https://docs.kapso.ai/docs/whatsapp/send-messages/text.md) for anything urgent.

## If you run out of balance

If you pay with Kapso credits and your balance can't cover the next template, sending pauses. Your messages stay in the queue. Top up and sending picks up where it left off within a couple of minutes.

The same thing happens if WhatsApp restricts your account or there is a payment problem: the queue waits until it's fixed.

Messages that wait longer than 4 hours expire.

## Look up a message

Webhooks tell you everything, but you can also ask. Pass up to 100 ids:

```bash REST API icon="code" theme={null}
curl 'https://api.kapso.ai/meta/whatsapp/v24.0/647015955153740/messages/batch?ids=0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40' \
  -H 'X-API-Key: YOUR_API_KEY'
```

```json theme={null}
{
  "messages": [
    {
      "id": "0d9f6c1e-2b7a-4f6e-9c1d-5a8e3b2f1c40",
      "biz_opaque_callback_data": "invoice-123",
      "status": "sent",
      "whatsapp_message_id": "wamid.HBgNMTU1NTEyMzQ1NjcVAgARGBI2RDhDNjY5",
      "queued_at": "2026-12-03T18:00:02Z",
      "finished_at": "2026-12-03T18:07:41Z"
    }
  ]
}
```

`status` is `queued`, `sent` or `failed`. Kapso keeps this for 3 days.

## Errors

A single message can be refused with:

| `code` | Meaning |
| - | - |
| `invalid_payload` | Something is missing or has the wrong format |
| `invalid_identifier` | `kapso.identifier` is not a string of 1 to 255 characters |
| `unsupported_type` | The message type can't be queued |
| `messaging_account_mismatch` | `messaging_account_id` doesn't belong to this number |

The whole request is refused with:

| Status | `code` | Meaning |
| - | - | - |
| `403` | None | Sandbox numbers can't use batch send |
| `422` | `missing_access_token` | The number is not connected through Kapso |
| `422` | `invalid_batch` | `messages` is missing or empty |
| `422` | `batch_too_large` | More than 100 messages |
| `422` | `invalid_idempotency_key` | The key is blank or longer than 255 characters |
| `409` | `idempotency_conflict` | You reused a key with a different body |
| `429` | `queue_full` | This number already has too many messages waiting |


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