Developers
KAPU SMS API
Send SMS from your own website, app or system: order confirmations, reminders, one-time codes and campaigns. The API lets you send single and bulk SMS, track delivery, and check your SMS balance.
https://sms.kapu.co.tz/api/v1
Quick start
You can send your first SMS in four steps.
-
Create an account and an application.
Sign up, then go to Applications
and create one for your website or system. Copy its API key: it starts with
sk_and is shown only once. -
Request a Sender ID.
This is the name your customers see instead of a number, like
YOURBRAND. Request it on the application; approval usually takes 1–2 working days. You don't have to wait: until it's approved, your messages go out asKAPU. - Buy SMS. Pick a bundle and pay with mobile money. Every SMS you send is taken from this balance.
-
Send your first SMS. Replace the API key, Sender ID and phone number below, and run it.
A
curl -X POST "https://sms.kapu.co.tz/api/v1/sms/send" \ -H "Authorization: Bearer sk_your_api_key" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"to":"0745520855","message":"Hello from my first API SMS!"}'<?php $ch = curl_init('https://sms.kapu.co.tz/api/v1/sms/send'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_HTTPHEADER => [ 'Authorization: Bearer sk_your_api_key', 'Accept: application/json', 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode([ 'to' => '0745520855', 'message' => 'Hello from my first API SMS!', ]), ]); $response = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);const response = await fetch('https://sms.kapu.co.tz/api/v1/sms/send', { method: 'POST', headers: { Authorization: 'Bearer sk_your_api_key', Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ "to": "0745520855", "message": "Hello from my first API SMS!" }), }); const data = await response.json();import requests response = requests.post( 'https://sms.kapu.co.tz/api/v1/sms/send', headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'}, json={ "to": "0745520855", "message": "Hello from my first API SMS!" }, ) data = response.json()202response means the message is on its way. Check its delivery with themessage_idyou get back.
Authentication
Every request must include your application's API key, in the Authorization header:
Authorization: Bearer sk_your_api_key
If your tool can't set that header, send the key as X-API-Key: sk_your_api_key instead.
Each application has its own key, Sender IDs and message history. Your SMS balance is shared by all your applications.
Requests and responses
- All requests use HTTPS and go to
https://sms.kapu.co.tz/api/v1. - Send request bodies as JSON, with
Content-Type: application/json. - Always send
Accept: application/json, so errors come back as JSON too. - Responses are JSON. Successful results are in
data; errors have amessageexplaining what went wrong. - Times are in UTC, in ISO 8601 format, e.g.
2026-09-29T08:15:02+00:00.
Let your users buy SMS
You can put a Buy SMS button inside your own website or app. Your user clicks it, picks how many SMS to buy and pays with mobile money on our secure page. The SMS are added to your balance. Your user never sees or types your API key: your server swaps it for a one-time link.
How it works
- Your user clicks "Buy SMS" in your system. The button goes to a page on your server.
- Your server asks us for a link with
POST /topup-links, using your API key. - Your server redirects the user's browser to the
urlwe return. - The user chooses a bundle and pays. They enter the mobile money number to pay from and approve the PIN prompt on their phone. You don't build any payment screens.
- The SMS are added to your balance within seconds of the payment. When the user clicks Done they return to your
return_url.
What your system needs to do
- Keep the API key on your server in an environment variable or secret store. It must never reach a browser, mobile app, HTML or JavaScript.
-
Add a "Buy SMS" route on your server that requires your user to be signed in, creates a link and redirects to it.
Here is the whole thing:
curl -X POST "https://sms.kapu.co.tz/api/v1/topup-links" \ -H "Authorization: Bearer sk_your_api_key" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"return_url":"https://yourapp.example/billing"}'// Laravel: the "Buy SMS" button links to this route Route::get('/buy-sms', function () { $response = Http::withToken(config('services.sms_gateway.key')) ->acceptJson() ->post('https://sms.kapu.co.tz/api/v1/topup-links', [ 'return_url' => route('billing'), ]); abort_unless($response->successful(), 502, 'Could not start the purchase.'); return redirect()->away($response->json('data.url')); })->middleware('auth');// Express: the "Buy SMS" button links to this route app.get('/buy-sms', requireLogin, async (req, res) => { const response = await fetch('https://sms.kapu.co.tz/api/v1/topup-links', { method: 'POST', headers: { Authorization: `Bearer ${process.env.SMS_GATEWAY_KEY}`, Accept: 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify({ return_url: 'https://yourapp.example/billing' }), }); if (!response.ok) return res.status(502).send('Could not start the purchase.'); const { data } = await response.json(); res.redirect(data.url); });# Flask: the "Buy SMS" button links to this route @app.get("/buy-sms") @login_required def buy_sms(): response = requests.post( "https://sms.kapu.co.tz/api/v1/topup-links", headers={"Authorization": f"Bearer {os.environ['SMS_GATEWAY_KEY']}", "Accept": "application/json"}, json={"return_url": "https://yourapp.example/billing"}, timeout=10, ) if not response.ok: abort(502, "Could not start the purchase.") return redirect(response.json()["data"]["url"]) -
Point your button at that route. A plain link is enough:
<a href="/buy-sms">Buy SMS</a> -
Optional: pass a
quantityto pre-fill the form, for example when your system knows how many SMS the user needs. The user can change it. -
Optional: show the new balance when they come back, using
GET /balance.
Rules for the link
- Create a new link for every click. Never save one or put it in a page or email.
- It works once and for 10 minutes. If the user opens it a second time or too late, they see "This link has expired" and have to click your button again.
- Redirect the browser straight to it. Don't paste it in a chat or email: a link preview can use it up before the user does.
- Once opened, the user has 30 minutes to finish buying. After that they click your button again.
- Only signed-in users should reach your route. Anyone who can click it can start a purchase that adds SMS to your balance, so protect it like any other page of your account area.
- Use an
httpsreturn_urlthat you control.
What can go wrong
| Where | Problem | What to do |
|---|---|---|
| Your server | 401 from /topup-links | The API key is missing or wrong. Check the Authorization header. |
| Your server | 403 from /topup-links | The application or account is suspended. Contact support. |
| Your server | 422 from /topup-links | The quantity or return_url is invalid. Fix the fields listed in errors. |
| Your server | 429 from /topup-links | Too many links requested (30 a minute). Wait and try again. |
| Your user | "This link has expired or was already used" | They go back to your site and click Buy SMS again. |
| Your user | The payment fails or times out | No SMS are added and they can try again on our page. Nothing for you to do. |
Test it before you go live
- Click your button while signed out of your own system. You should be asked to sign in first.
- Click it while signed in: you should land on our buy page without being asked for a key.
- Go back and reload the link. It should say it expired.
- Buy a small bundle. Your balance should go up by that many SMS.
- Click Done: you should return to your
return_url.
Send an SMS
/sms/send
Sends one message to one phone number. The message is queued straight away and your SMS balance is charged.
Parameters JSON body
| Name | Type | Description |
|---|---|---|
sender_id
|
string | Optional. One of your approved Sender IDs, e.g. YOURBRAND, or the default KAPU. Leave it out to use your only approved Sender ID, or KAPU while you have none. See Sender IDs. |
to
required
|
string | The recipient's Tanzanian mobile number. See phone number formats. |
message
required
|
string | The text to send, up to 1,000 characters. Long messages are sent in parts; see how messages are charged. |
Example request
curl -X POST "https://sms.kapu.co.tz/api/v1/sms/send" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"sender_id":"YOURBRAND","to":"0745520855","message":"Habari! Oda yako imefika."}'
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/sms/send');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'sender_id' => 'YOURBRAND',
'to' => '0745520855',
'message' => 'Habari! Oda yako imefika.',
]),
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/sms/send', {
method: 'POST',
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "YOURBRAND",
"to": "0745520855",
"message": "Habari! Oda yako imefika."
}),
});
const data = await response.json();
import requests
response = requests.post(
'https://sms.kapu.co.tz/api/v1/sms/send',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
json={
"sender_id": "YOURBRAND",
"to": "0745520855",
"message": "Habari! Oda yako imefika."
},
)
data = response.json()
Example response
202 Accepted The message is queued and your balance has been charged.
{
"message": "Message queued.",
"sms_used": 1,
"data": [
{
"message_id": "SMS-20260929-K3M9Q2XA7B",
"recipient": "255745520855",
"sender_id": "YOURBRAND",
"message": "Habari! Oda yako imefika.",
"status": "queued",
"sms_count": 1,
"failure_code": null,
"failure_reason": null,
"queued_at": "2026-09-29T08:15:02+00:00",
"sent_at": null,
"delivered_at": null,
"failed_at": null
}
]
}
Save the message_id to check whether the message was delivered.
Send bulk SMS
/sms/bulk
Sends the same message to many phone numbers in one request.
Parameters JSON body
| Name | Type | Description |
|---|---|---|
sender_id
|
string | Optional. One of your approved Sender IDs, e.g. YOURBRAND, or the default KAPU. Leave it out to use your only approved Sender ID, or KAPU while you have none. See Sender IDs. |
recipients
required
|
array of strings | Up to 1,000 phone numbers. The same number written two ways (e.g. 0745520855 and +255745520855) is sent to once. |
message
required
|
string | The text to send, up to 1,000 characters. |
Example request
curl -X POST "https://sms.kapu.co.tz/api/v1/sms/bulk" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"sender_id":"YOURBRAND","recipients":["0745520855","0685111222","+255 712 333 444"],"message":"Ofa ya leo: punguzo la 20% kwa bidhaa zote."}'
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/sms/bulk');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'sender_id' => 'YOURBRAND',
'recipients' => [
'0745520855',
'0685111222',
'+255 712 333 444',
],
'message' => 'Ofa ya leo: punguzo la 20% kwa bidhaa zote.',
]),
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/sms/bulk', {
method: 'POST',
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "YOURBRAND",
"recipients": [
"0745520855",
"0685111222",
"+255 712 333 444"
],
"message": "Ofa ya leo: punguzo la 20% kwa bidhaa zote."
}),
});
const data = await response.json();
import requests
response = requests.post(
'https://sms.kapu.co.tz/api/v1/sms/bulk',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
json={
"sender_id": "YOURBRAND",
"recipients": [
"0745520855",
"0685111222",
"+255 712 333 444"
],
"message": "Ofa ya leo: punguzo la 20% kwa bidhaa zote."
},
)
data = response.json()
Example responses
202 Accepted One entry in data per recipient.
{
"message": "3 messages queued.",
"sms_used": 3,
"data": [
{
"message_id": "SMS-20260929-K3M9Q2XA7B",
"recipient": "255745520855",
"sender_id": "YOURBRAND",
"message": "Habari! Oda yako imefika.",
"status": "queued",
"sms_count": 1,
"failure_code": null,
"failure_reason": null,
"queued_at": "2026-09-29T08:15:02+00:00",
"sent_at": null,
"delivered_at": null,
"failed_at": null
},
{
"message_id": "SMS-20260929-P7D2L9WQ4M",
"recipient": "255685111222",
"…": "…"
},
{
"message_id": "SMS-20260929-H5T8R1ZC6N",
"recipient": "255712333444",
"…": "…"
}
]
}
402 Payment Required Your balance can't cover every recipient. Nothing was sent or charged.
{
"message": "Not enough SMS balance: this request needs 3 SMS and you have 2. Buy more SMS to continue.",
"balance": 2,
"required": 3
}
It's all or nothing: if one number is invalid or the balance is short, no message is sent.
For more than 1,000 numbers, split them over several requests.
Get a message and its delivery report
/sms/{message_id}
Returns one message with its current status and the delivery reports received from the network.
Parameters URL
| Name | Type | Description |
|---|---|---|
message_id
required
|
string | The message_id returned when the message was sent. |
Example request
curl "https://sms.kapu.co.tz/api/v1/sms/SMS-20260929-K3M9Q2XA7B" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json"
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/sms/SMS-20260929-K3M9Q2XA7B');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
],
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/sms/SMS-20260929-K3M9Q2XA7B', {
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
},
});
const data = await response.json();
import requests
response = requests.get(
'https://sms.kapu.co.tz/api/v1/sms/SMS-20260929-K3M9Q2XA7B',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
)
data = response.json()
Example responses
200 OK
{
"data": {
"message_id": "SMS-20260929-K3M9Q2XA7B",
"recipient": "255745520855",
"sender_id": "YOURBRAND",
"message": "Habari! Oda yako imefika.",
"status": "delivered",
"sms_count": 1,
"failure_code": null,
"failure_reason": null,
"queued_at": "2026-09-29T08:15:02+00:00",
"sent_at": "2026-09-29T08:15:04+00:00",
"delivered_at": "2026-09-29T08:15:40+00:00",
"failed_at": null,
"delivery_reports": [
{
"status": "delivered",
"network_status": "DELIVRD",
"received_at": "2026-09-29T08:15:40+00:00"
}
]
}
}
404 Not Found No message with that ID was sent by this application.
{
"message": "Not found."
}
delivery_reports stays empty until the network reports back, usually within a minute of sending.
List messages
/sms
Lists the messages sent by this application, newest first. Use it to check the status of many messages at once.
Parameters query string (all optional)
| Name | Type | Description |
|---|---|---|
status
|
string | queued, processing, sent, delivered or failed. |
recipient
|
string | Only messages to this phone number. |
from
|
date | Sent on or after this date, e.g. 2026-09-01. |
to
|
date | Sent on or before this date. |
per_page
|
integer | Messages per page, 1 to 100. Default 50. |
page
|
integer | Page number. Default 1. |
Example request
curl "https://sms.kapu.co.tz/api/v1/sms?status=failed&from=2026-09-01&per_page=100" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json"
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/sms?status=failed&from=2026-09-01&per_page=100');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
],
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/sms?status=failed&from=2026-09-01&per_page=100', {
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
},
});
const data = await response.json();
import requests
response = requests.get(
'https://sms.kapu.co.tz/api/v1/sms?status=failed&from=2026-09-01&per_page=100',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
)
data = response.json()
Example response
200 OK Paging details are in links and meta.
{
"data": [
{
"message_id": "SMS-20260929-K3M9Q2XA7B",
"recipient": "255745520855",
"sender_id": "YOURBRAND",
"message": "Habari! Oda yako imefika.",
"status": "failed",
"sms_count": 1,
"failure_code": "UNDELIV",
"failure_reason": "The phone was switched off.",
"queued_at": "2026-09-29T08:15:02+00:00",
"sent_at": null,
"delivered_at": null,
"failed_at": "2026-09-29T08:20:11+00:00"
}
],
"links": {
"first": "https://sms.kapu.co.tz/api/v1/sms?page=1",
"last": "https://sms.kapu.co.tz/api/v1/sms?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"last_page": 1,
"per_page": 100,
"total": 1,
"…": "…"
}
}
Check your SMS balance
/balance
Returns how many SMS you have left. The balance is shared by all your applications.
Example request
curl "https://sms.kapu.co.tz/api/v1/balance" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json"
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/balance');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
],
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/balance', {
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
},
});
const data = await response.json();
import requests
response = requests.get(
'https://sms.kapu.co.tz/api/v1/balance',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
)
data = response.json()
Example response
200 OK
{
"data": {
"balance": 4820,
"unit": "sms"
}
}
Check it before a large campaign, or alert yourself when it runs low.
Let your users buy SMS
/topup-links
Creates a one-time link for one of your users. Send their browser to it (for example from a "Buy SMS" button) and they pick a bundle and pay with mobile money, without ever seeing your API key. The SMS are added to your balance.
Parameters JSON body (all optional)
| Name | Type | Description |
|---|---|---|
quantity
|
integer | Pre-fills the number of SMS on the buy page. The user can change it. |
return_url
|
string | An https address to send the user back to when they click Done after buying. |
Example request
curl -X POST "https://sms.kapu.co.tz/api/v1/topup-links" \
-H "Authorization: Bearer sk_your_api_key" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"quantity":5000,"return_url":"https://yourapp.example/billing"}'
<?php
$ch = curl_init('https://sms.kapu.co.tz/api/v1/topup-links');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer sk_your_api_key',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'quantity' => 5000,
'return_url' => 'https://yourapp.example/billing',
]),
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
const response = await fetch('https://sms.kapu.co.tz/api/v1/topup-links', {
method: 'POST',
headers: {
Authorization: 'Bearer sk_your_api_key',
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"quantity": 5000,
"return_url": "https://yourapp.example/billing"
}),
});
const data = await response.json();
import requests
response = requests.post(
'https://sms.kapu.co.tz/api/v1/topup-links',
headers={'Authorization': 'Bearer sk_your_api_key', 'Accept': 'application/json'},
json={
"quantity": 5000,
"return_url": "https://yourapp.example/billing"
},
)
data = response.json()
Example response
201 Created Redirect the user to url within 10 minutes. It works once.
{
"data": {
"url": "https://sms.kapu.co.tz/topup/start/…",
"expires_at": "2026-11-11T09:40:00+00:00"
}
}
Call this from your server, never from a browser or app, because it uses your API key. Make a new link every time a user clicks the button.
Do not email or share the link: whoever opens it first can buy SMS for your balance.
Sender IDs
The Sender ID is the name your customers see as the sender, instead of a phone number. Each application has its own Sender IDs, and each one is checked by our team before it can be used.
Which Sender ID a message goes out as:
| You send | Your application has | Sent as |
|---|---|---|
sender_id set |
That Sender ID, approved | That Sender ID |
No sender_id |
One approved Sender ID | That Sender ID |
No sender_id |
Several approved Sender IDs | Error 422: choose one |
No sender_id |
No approved Sender ID yet |
The default, KAPU
|
KAPU.
New customers can send with our default Sender ID while their own is being reviewed, so you can build and test your integration from day one.
You can also name it: "sender_id": "KAPU".
Messages sent this way are charged the same as any other.
Every message in a response shows the Sender ID it actually went out as, in sender_id.
Message statuses
A message moves through these statuses, left to right:
| Status | Meaning |
|---|---|
queued | Accepted and waiting to be sent. Your balance has been charged. |
processing | Being handed to the mobile network. |
sent | Accepted by the network, which is delivering it to the phone. |
delivered | The phone received the message. Final. |
failed | The message couldn't be delivered; failure_reason says why. Final. The SMS are refunded to your balance. |
A message can stay sent if the network never reports back, for example when the phone is off for a long time.
Networks keep trying for up to 48 hours.
How messages are charged
Each message costs 1 SMS or more from your balance, depending on its length and characters.
sms_count on each message shows what it used, and sms_used on the send response shows the total.
| Message type | 1 SMS | Longer messages |
|---|---|---|
| Plain text Letters, numbers and common symbols |
Up to 160 characters | 153 characters per SMS |
| Unicode Contains emoji, curly quotes or other special characters |
Up to 70 characters | 67 characters per SMS |
For example, a 200-character plain message costs 2 SMS, so sending it to 100 people costs 200 SMS.
The characters ^ { } [ ] ~ | € \ count as two.
Phone number formats
Send to Tanzanian mobile numbers, in any of these formats. They're all the same number:
255745520855international, recommended+255 745 520 855with + and spaces0745520855local, with the leading 0745520855without the leading 0
Responses always show numbers in the international format, e.g. 255745520855.
Errors
Errors use standard HTTP status codes, and the body always has a message you can show or log.
| Status | Meaning | What to do |
|---|---|---|
| 401 | The API key is missing or wrong. | Check the Authorization header and the key. |
| 402 | Not enough SMS balance. Nothing was sent. | Buy more SMS. The body includes balance and required. |
| 403 | The application or account is suspended. | Contact support. |
| 404 | No such message on this application, or a wrong URL. | Check the message_id and path. |
| 422 | The request is invalid, e.g. a wrong phone number or a Sender ID that isn't approved. | Fix the fields listed in errors. |
| 429 | Too many requests. | Wait a minute and try again. See rate limits. |
| 5xx | Something went wrong on our side. | Try again later. Check your messages first, so you don't send twice. |
A 422 response lists every problem, by field:
{
"message": "Sender ID NEWBRAND is pending; only approved Sender IDs can send. (and 1 more error)",
"errors": {
"sender_id": [
"Sender ID NEWBRAND is pending; only approved Sender IDs can send."
],
"recipients.2": [
"Recipient 3 is not a Tanzanian mobile number, e.g. 255745520855."
]
}
}
Rate limits
Each application can make up to 120 requests a minute. Above that you get a 429 response;
the Retry-After header says how many seconds to wait.
To message many people, use bulk SMS: one request reaches up to 1,000 numbers.
Best practices
- Keep the API key on your server, in an environment variable or secret store, not in your code repository.
- Save each
message_idwith your own record (order, customer), so you can look up its delivery later. - Don't resend on a timeout straight away. The first request may have worked. Check your recent messages for that number first.
- Check delivery in batches with List messages rather than one request per message.
- Check your balance before large campaigns, so a
402doesn't stop them halfway. - Only message people who agreed to hear from you, and tell them how to opt out.
Support
Stuck, or found something unclear? We're happy to help with your integration.
When you contact us about a message, include its message_id.