Bulk messages
Send up to 1,000 messages in a single request, each with its own recipient and text.
Endpoint
POST https://api.sms.pesarails.com/v1/messages/bulkRequest
Pass an array of messages and the sender ID they all go out from.
curl https://api.sms.pesarails.com/v1/messages/bulk \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sender": "PESARAILS",
"messages": [
{ "to": "0712345678", "text": "Hi Alice, your code is 4821", "ref": "u-1" },
{ "to": "0722000111", "text": "Hi Bob, your code is 9930", "ref": "u-2" }
]
}'Response
You get a summary plus a per-message result, so you know exactly which ones were accepted.
{
"accepted": 2,
"failed": 0,
"rejected": [],
"messages": [
{ "messageId": "a1b2c3", "to": "254712345678", "status": "sent" },
{ "messageId": "d4e5f6", "to": "254722000111", "status": "sent" }
]
}Note
rejected lists numbers that were never charged, for example an invalid format or a
recipient you ran out of credit for partway through. Everything in messages was
reserved and sent.
Limits
- Up to 1,000 messages per request.
- Each message is billed per segment, like a single send.
- Use
refto match results back to your own records.