API Docs

SMS API

Send single, bulk and scheduled SMS or WhatsApp template messages.

Send one message or thousands in a single request, schedule them for later, or send approved WhatsApp templates. Then list your history or fetch a single message to see its delivery status.

Send SMS

POST/messagesAPI key

Creates and queues one or more messages. The whole request succeeds or fails together: if any message is invalid or your balance can't cover all of them, nothing is sent and nothing is charged.

  • sender_name, if given, must be approved, enabled, and yours (created by you, assigned to you, or a shared default).
  • Recipients you haven't messaged before are saved as contacts automatically.
  • Your SMS balance (or postpaid limit) is checked and charged in the same step.
Body
sender_namestringoptional
An approved sender name, e.g. NBM. Leave it out to send without one. Ignored for WhatsApp.
messagesarrayrequired
One or more { receiver, content } objects. Can't be empty.
messages[].receiverstringrequired
The recipient's phone number, local or international. See phone number format.
messages[].contentstringrequired
The text, up to 1600 characters. See billing for how length is counted.
is_scheduledbooleanoptionaldefault: false
Set to true to send later. Requires scheduled_date.
scheduled_datestring (ISO 8601)optional
When to send, e.g. 2026-12-01T07:00:00+03:00. Must be in the future. The message waits as scheduled, then moves to sending.
channelstringoptionaldefault: sms
sms or whatsapp. See Send via WhatsApp.
Single message
curl -X POST https://sms.nbmbrand.com/api/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-2041-ready" \
  -d '{
    "sender_name": "NBM",
    "messages": [
      {
        "receiver": "0712345678",
        "content": "Hello Asha, your order NBM-2041 is ready for pickup."
      }
    ]
  }'
Response
201 Created
{
  "success": true,
  "status_code": 201,
  "status_text": "Created",
  "message": "messages have been created",
  "data": null
}

Bulk messages

Put as many entries in messages as you need — each can have different text, so personalised campaigns need only one request. For very large campaigns, send batches of up to 1,000 messages per request.

Bulk messages
curl -X POST https://sms.nbmbrand.com/api/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "sender_name": "NBM",
    "messages": [
      {
        "receiver": "0712345678",
        "content": "Hi Asha, your NBM points balance is 1,250."
      },
      {
        "receiver": "0754987654",
        "content": "Hi Juma, your NBM points balance is 430."
      },
      {
        "receiver": "255688112233",
        "content": "Hi Neema, your NBM points balance is 2,900."
      }
    ]
  }'

Scheduled send

Scheduled messages are charged when you create them, so the balance is reserved. Include a timezone offset in scheduled_date (Tanzania is +03:00); a date without one is treated as UTC.

Scheduled send
curl -X POST https://sms.nbmbrand.com/api/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "sender_name": "NBM",
    "is_scheduled": true,
    "scheduled_date": "2026-12-01T07:00:00+03:00",
    "messages": [
      {
        "receiver": "0712345678",
        "content": "Black Friday starts now — up to 50% off at NBM."
      }
    ]
  }'
Errors
StatuserrorWhen it happens
400validation_errormessages is missing or empty, a receiver or content is missing, or scheduled_date is missing or in the past.
400creation_errorThe sender name isn't approved, is disabled or isn't yours, or your balance / postpaid limit can't cover the messages.
400idempotency_conflictThe Idempotency-Key was already used with a different body.
401invalid_tokenMissing or invalid API key.

Message length & billing

SMS are billed in units. Long messages are split into parts by the network and joined again on the phone; each part costs one unit. Part size depends on the characters you use:

Text type1 unitEach part when longerExamples
Plain (GSM-7: A–Z, 0–9, common punctuation)up to 160 chars153 chars160 → 1 · 161 → 2 · 306 → 2 · 307 → 3 · 475 → 4
Unicode (emoji, curly quotes, non-Latin scripts)up to 70 chars63 chars70 → 1 · 71 → 2 · 126 → 2 · 127 → 3

The number of units is returned as count on each message. Accounts with staff (admin) rights in the portal send without being charged.

Safe retries (Idempotency-Key)

If a send times out or the connection drops, you can't tell whether the messages were created. Retrying blindly could text your customers twice — and charge you twice.

Send an Idempotency-Key header with every POST /messages: any string up to 128 printable characters, unique per send (an order id, or a UUID you store before sending).

  • Repeating the request with the same key and body doesn't create or charge anything again; you get 200 OK saying the messages already exist.
  • Reusing a key with a different body is refused with idempotency_conflict.
  • Keys are remembered for 48 hours.
Repeated request, same key
200 OK
{
  "success": true,
  "status_code": 200,
  "status_text": "OK",
  "message": "messages have already been created",
  "data": null
}

Send via WhatsApp

POST/messagesAPI key

Uses the same endpoint with channel: "whatsapp". WhatsApp only allows business-initiated messages from approved templates, so you send a template id and the values for its placeholders instead of free text. Templates are created and submitted for approval in the portal's WhatsApp section.

Body
channelstringrequired
Must be whatsapp.
template_iduuidrequired
An approved WhatsApp template from your account.
whatsapp_sourcestringoptionaldefault: default
default sends from the shared NBM WhatsApp number; own sends from your own connected business number.
messages[].receiverstringrequired
The recipient's WhatsApp number.
messages[].template_paramsstring[]optional
Values for the template's {{1}}, {{2}}… placeholders, in order.
messages[].contentstringoptional
Ignored for WhatsApp; send an empty string.
Errors
StatuserrorWhen it happens
400validation_errortemplate_id missing or a receiver missing.
400creation_errorTemplate not approved, WhatsApp isn't set up on your account, your own number isn't active (with own), or the WhatsApp wallet is too low.
WhatsApp template
curl -X POST https://sms.nbmbrand.com/api/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "whatsapp",
    "template_id": "5c0d8a2e-9b1f-4c3d-8e7a-6f5b4a3c2d1e",
    "whatsapp_source": "default",
    "messages": [
      {
        "receiver": "0712345678",
        "content": "",
        "template_params": [
          "Asha",
          "NBM-2041",
          "Kariakoo branch"
        ]
      }
    ]
  }'
Response
201 Created
{
  "success": true,
  "status_code": 201,
  "status_text": "Created",
  "message": "messages have been created",
  "data": null
}

List messages

GET/messagesAPI key

Returns your messages, newest first, one page at a time.

Query
pageintegeroptionaldefault: 1
Page number.
limitintegeroptionaldefault: 10
Records per page, up to 1000.
sort_bystringoptionaldefault: created_at
One of status, count, is_scheduled, scheduled_date, created_at, updated_at.
sort_dirstringoptionaldefault: desc
asc or desc.
statusstringoptional
Only messages with this status.
scheduledbooleanoptional
true for scheduled messages only, false to exclude them.
channelstringoptional
sms or whatsapp.
curl "https://sms.nbmbrand.com/api/v1/messages?page=1&limit=20&status=delivered&sort_dir=desc" \
  -H "Authorization: Bearer $API_KEY"
Response
200 OK
{
  "success": true,
  "status_code": 200,
  "status_text": "OK",
  "message": "messages have been fetched",
  "data": {
    "data": [
      {
        "id": "6b2f6e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
        "status": "delivered",
        "content": "Hello Asha, your order NBM-2041 is ready for pickup.",
        "count": 1,
        "sender_name": "NBM",
        "sender_name_id": "9a1c1e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
        "phone_number": "255712345678",
        "contact_id": "c41d2b8e-7f3a-4e21-9b8c-2d5f6a7e8b9c",
        "contact_name": "Asha Mushi",
        "is_scheduled": false,
        "scheduled_date": null,
        "message_id": "prv-88213470",
        "channel": "sms",
        "template_id": null,
        "template_name": null,
        "whatsapp_number": null,
        "whatsapp_phone_number_id": null,
        "next_check_at": null,
        "failure_reason": null,
        "created_by": "2f0b6c1d-1e2a-4b3c-8d9e-0f1a2b3c4d5e",
        "created_by_name": "Shop API",
        "created_at": "2026-11-20T09:14:03Z",
        "updated_by": null,
        "updated_by_name": null,
        "updated_at": "2026-11-20T09:14:41Z"
      }
    ],
    "total": 1,
    "page": 1,
    "limit": 20,
    "total_pages": 1,
    "has_next_page": false,
    "has_previous_page": false,
    "next_page": null,
    "previous_page": null
  }
}

Search messages

GET/messages/searchAPI key

Like List messages, plus a required searchterm matched against the message text and the recipient's number or contact name. Accepts the same filters and pagination.

Query
searchstringrequired
Text or phone number to look for.
curl "https://sms.nbmbrand.com/api/v1/messages/search?search=NBM-2041&limit=20" \
  -H "Authorization: Bearer $API_KEY"

Get a message

GET/messages/{id}API key

Fetches one message, including sender, recipient and contact names. Use it after a webhook to get full details.

Path
iduuidrequired
The message id.
Errors
StatuserrorWhen it happens
400invalid_parameterid isn't a valid UUID.
404not_foundNo message with that id belongs to you.
curl https://sms.nbmbrand.com/api/v1/messages/6b2f6e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f \
  -H "Authorization: Bearer $API_KEY"
Response
200 OK
{
  "success": true,
  "status_code": 200,
  "status_text": "OK",
  "message": "message has been fetched",
  "data": {
    "id": "6b2f6e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
    "status": "delivered",
    "content": "Hello Asha, your order NBM-2041 is ready for pickup.",
    "count": 1,
    "sender_name": "NBM",
    "sender_name_id": "9a1c1e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
    "phone_number": "255712345678",
    "contact_id": "c41d2b8e-7f3a-4e21-9b8c-2d5f6a7e8b9c",
    "contact_name": "Asha Mushi",
    "is_scheduled": false,
    "scheduled_date": null,
    "message_id": "prv-88213470",
    "channel": "sms",
    "template_id": null,
    "template_name": null,
    "whatsapp_number": null,
    "whatsapp_phone_number_id": null,
    "next_check_at": null,
    "failure_reason": null,
    "created_by": "2f0b6c1d-1e2a-4b3c-8d9e-0f1a2b3c4d5e",
    "created_by_name": "Shop API",
    "created_at": "2026-11-20T09:14:03Z",
    "updated_by": null,
    "updated_by_name": null,
    "updated_at": "2026-11-20T09:14:41Z"
  }
}
Response
404 Not Found
{
  "success": false,
  "status_code": 404,
  "status_text": "Not Found",
  "message": "message not found",
  "error": "not_found"
}

The message object

Fields
iduuidrequired
Message id. Use it to fetch the message and to match webhooks.
statusstringrequired
Current status.
contentstringrequired
The text that was sent (empty for WhatsApp).
countintegerrequired
Units billed. See billing.
channelstringrequired
sms or whatsapp.
phone_numberstringrequired
Recipient in international format.
sender_name / sender_name_idstring | nulloptional
The sender name used, if any.
contact_id / contact_namestring | nulloptional
The saved contact for this number.
is_scheduled / scheduled_dateboolean / string | nulloptional
Whether the message was scheduled, and for when.
message_idstring | nulloptional
The network operator's reference, once the message has been handed over.
template_id / template_namestring | nulloptional
WhatsApp template used.
whatsapp_number / whatsapp_phone_number_idstring | nulloptional
WhatsApp number the message was sent from.
failure_reasonstring | nulloptional
Why the message was failed or undelivered, when known.
next_check_atstring | nulloptional
When the delivery status will next be checked.
created_by / created_by_namestringoptional
The user or API key that sent it.
created_at / updated_atstring (ISO 8601)required
Timestamps, in UTC.

Message statuses

scheduledsending
processing
sent
deliveredundeliveredfailed
StatusMeaningFinal?
scheduledWaiting for its scheduled_date.No
sendingAccepted and queued to go out now.No
processingBeing handed to the mobile network.No
processing_statusWaiting for the network's delivery report.No
sentThe network accepted it; the phone hasn't confirmed yet (it may be off or out of coverage).No
deliveredThe handset confirmed receipt.Yes
undeliveredThe network gave up — number unreachable, inactive or blocked.Yes
failedWe couldn't send it (e.g. invalid number, operator rejected it). See failure_reason.Yes

Delivery status is checked about every 30 seconds. The final delivered and undelivered changes are pushed to your webhook.