Skip to main content
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. For a single message that should go out right now, use the regular send.

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.
REST API
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.
  • biz_opaque_callback_data is your own name for the message. See follow each message.
You can send up to 100 messages per request. A batch counts as one request toward your rate limit.

What you get back

Kapso answers immediately with one line per message, in the same order you sent them:
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:
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 as for any other send: whatsapp.message.sent, then delivered and read, or failed. Your reference is inside message.kapso:
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:
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

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:
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:
  • 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 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:
REST API
status is queued, sent or failed. Kapso keeps this for 3 days.

Errors

A single message can be refused with: The whole request is refused with: