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.

Base URL
https://sms.kapu.co.tz/api/v1

Quick start

You can send your first SMS in four steps.

  1. 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.
  2. 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 as KAPU.
  3. Buy SMS. Pick a bundle and pay with mobile money. Every SMS you send is taken from this balance.
  4. Send your first SMS. Replace the API key, Sender ID and phone number below, and run it.
    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!"}'
    A 202 response means the message is on its way. Check its delivery with the message_id you 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.

Keep your API key secret. Anyone with it can send SMS from your balance. Only use it on your server, never in a website's JavaScript or a mobile app. If it leaks, create a new key on the Applications page: the old one stops working immediately.

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 a message explaining 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

  1. Your user clicks "Buy SMS" in your system. The button goes to a page on your server.
  2. Your server asks us for a link with POST /topup-links, using your API key.
  3. Your server redirects the user's browser to the url we return.
  4. 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.
  5. 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

  1. 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.
  2. 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"}'
  3. Point your button at that route. A plain link is enough:
    <a href="/buy-sms">Buy SMS</a>
  4. Optional: pass a quantity to pre-fill the form, for example when your system knows how many SMS the user needs. The user can change it.
  5. 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 https return_url that you control.

What can go wrong

WhereProblemWhat to do
Your server401 from /topup-linksThe API key is missing or wrong. Check the Authorization header.
Your server403 from /topup-linksThe application or account is suspended. Contact support.
Your server422 from /topup-linksThe quantity or return_url is invalid. Fix the fields listed in errors.
Your server429 from /topup-linksToo 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 userThe payment fails or times outNo 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

POST /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."}'

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

POST /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."}'

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

GET /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"

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

GET /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"

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

GET /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"

Example response

200 OK

{
  "data": {
    "balance": 4820,
    "unit": "sms"
  }
}

Check it before a large campaign, or alert yourself when it runs low.

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
Test straight away with 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
queuedAccepted and waiting to be sent. Your balance has been charged.
processingBeing handed to the mobile network.
sentAccepted by the network, which is delivering it to the phone.
deliveredThe phone received the message. Final.
failedThe 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.

Tip: a single emoji or a curly apostrophe (’ instead of ') turns the whole message into Unicode, which more than doubles its cost. Use plain characters to keep costs down.

Phone number formats

Send to Tanzanian mobile numbers, in any of these formats. They're all the same number:

  • 255745520855 international, recommended
  • +255 745 520 855 with + and spaces
  • 0745520855 local, with the leading 0
  • 745520855 without 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
401The API key is missing or wrong.Check the Authorization header and the key.
402Not enough SMS balance. Nothing was sent.Buy more SMS. The body includes balance and required.
403The application or account is suspended.Contact support.
404No such message on this application, or a wrong URL.Check the message_id and path.
422The request is invalid, e.g. a wrong phone number or a Sender ID that isn't approved.Fix the fields listed in errors.
429Too many requests.Wait a minute and try again. See rate limits.
5xxSomething 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_id with 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 402 doesn'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.