Send from your own system.

One call to send an SMS from your own system. It has a working example in cURL, PHP, Node.js and Python that you can copy as it is.

Base URL https://nuntio.africa/api/v1
Send your first SMS
curl -X POST https://nuntio.africa/api/v1/sms/send \
  -H "X-API-Key: $NUNTIO_KEY" \
  -H "X-API-Secret: $NUNTIO_SECRET" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "0712345678",
    "message": "Habari kutoka Nuntio!"
}'
$res = nuntio('POST', '/sms/send', [
    'to' => '0712345678',
    'message' => 'Habari kutoka Nuntio!',
]);

print_r($res);
const res = await nuntio('POST', '/sms/send', {
    "to": "0712345678",
    "message": "Habari kutoka Nuntio!"
});

console.log(res);
res = nuntio("POST", "/sms/send", {
    "to": "0712345678",
    "message": "Habari kutoka Nuntio!"
})

print(res)

Overview

You call https://nuntio.africa/api/v1 over HTTPS with JSON, signed with your API key. We deliver to Vodacom, Airtel, Tigo and Halotel, and charge credits from your wallet only for messages the network accepts.

The API does one thing: send an SMS. Creating keys, buying credits, sender names, contacts, campaigns and reports are all done in your dashboard.

Quick start

Three steps, about five minutes.

Create an API keyIn the dashboard under Developers → API keys. You get a key ID (spk_…) and a secret (sps_…). The secret is shown once: save it now.
Top up creditsOne credit sends one SMS part. Pay with mobile money under Billing. The API answers 402 when the wallet is empty.
SendCopy the example at the top of this page, put in your key and a real number, and run it. The answer tells you the message ID and the credits used.

Keep the secret on your server. Never put it in a mobile app, a web page or a public repository. If it leaks, revoke the key in the dashboard and create a new one.

Helper functions

Copy this small file into your project once. It gives you one function that talks to the API, nuntio(), and a ready-made sendSms():

FunctionWhat it does
sendSms(to, message, from)Sends one SMS and returns the API answer.

The PHP, Node.js and Python examples on this page all use nuntio() from this file. It reads your key from the environment variables NUNTIO_KEY and NUNTIO_SECRET, so the secret never sits in your code.

Every answer also carries http_status, so you can tell a 402 from a 422 without extra code.

nuntio helper
# Put your key in the environment once, then every example below works as written.
export NUNTIO_KEY="spk_your_key_id"
export NUNTIO_SECRET="sps_your_secret"

curl -X POST https://nuntio.africa/api/v1/sms/send \
  -H "X-API-Key: $NUNTIO_KEY" \
  -H "X-API-Secret: $NUNTIO_SECRET" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"to": "0712345678", "message": "Habari!"}'
<?php
// nuntio.php — include this file, then call the functions below.
const NUNTIO_BASE = 'https://nuntio.africa/api/v1';

function nuntio(string $method, string $path, array $body = []): array
{
    $ch = curl_init(NUNTIO_BASE . $path);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT        => 30,
        CURLOPT_HTTPHEADER     => [
            'X-API-Key: ' . getenv('NUNTIO_KEY'),
            'X-API-Secret: ' . getenv('NUNTIO_SECRET'),
            'Content-Type: application/json',
            'Accept: application/json',
        ],
    ]);
    if ($body) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    }
    $raw = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    return ['http_status' => $status] + (json_decode((string) $raw, true) ?? []);
}

/** Send one SMS. Returns the API answer; check $res['success']. */
function sendSms(string $to, string $message, ?string $from = null): array
{
    return nuntio('POST', '/sms/send', array_filter(['to' => $to, 'message' => $message, 'from' => $from]));
}
// nuntio.js — Node.js 18 or newer (built-in fetch).
const BASE = 'https://nuntio.africa/api/v1';

async function nuntio(method, path, body) {
  const res = await fetch(BASE + path, {
    method,
    headers: {
      'X-API-Key': process.env.NUNTIO_KEY,
      'X-API-Secret': process.env.NUNTIO_SECRET,
      'Content-Type': 'application/json',
      Accept: 'application/json',
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json().catch(() => ({}));

  return { http_status: res.status, ...data };
}

/** Send one SMS. Check res.success. */
const sendSms = (to, message, from) => nuntio('POST', '/sms/send', { to, message, from });

module.exports = { nuntio, sendSms };
# nuntio.py — pip install requests
import os
import requests

BASE = "https://nuntio.africa/api/v1"


def nuntio(method, path, body=None):
    res = requests.request(
        method,
        BASE + path,
        json=body,
        timeout=30,
        headers={
            "X-API-Key": os.environ["NUNTIO_KEY"],
            "X-API-Secret": os.environ["NUNTIO_SECRET"],
            "Accept": "application/json",
        },
    )
    try:
        data = res.json()
    except ValueError:
        data = {}
    return {"http_status": res.status_code, **data}


def send_sms(to, message, sender=None):
    """Send one SMS. Check res["success"]."""
    body = {"to": to, "message": message}
    if sender:
        body["from"] = sender
    return nuntio("POST", "/sms/send", body)

Authentication

Send both headers on every request. The key ID alone is not enough.

HeaderValue
X-API-KeyYour key ID, starts with spk_.
X-API-SecretYour secret, starts with sps_.
Acceptapplication/json
Content-Typeapplication/json on requests with a body.

Permissions

Each key only does what you tick when you create it. A call outside its permissions returns 403 insufficient_scope.

PermissionAllows
sms:sendSend SMS.
Headers
X-API-Key: spk_Xk2mP9qLr4TnB7aW
X-API-Secret: sps_…
Accept: application/json
Content-Type: application/json
Wrong or missing key · 401
{
    "success": false,
    "error": "invalid_credentials",
    "message": "Invalid or revoked API credentials."
}

Phone numbers

Tanzanian mobile numbers, written any of these ways: 0712345678, 712345678, 255712345678 or +255712345678. We always answer with the full form 255712345678, so store that one. Anything else returns 422.

Errors

Success is 2xx with "success": true. Everything else has "success": false and says why. Two shapes exist:

  • Most errors: error (a short code) and message (a sentence you can show).
  • A send the gateway refused: error_code (capitals) and error_message.
HTTPCodeWhat to do
401missing_credentials
invalid_credentials
Check both headers. The key may be revoked or expired.
402insufficient_balance
INSUFFICIENT_BALANCE
Top up, then retry.
403insufficient_scope
account_disabled
Tick the permission on the key, or contact support.
422validation, invalid_sender, INVALID_PHONE, CONTENT_BLOCKEDFix the request. Validation errors list each field under errors. Do not retry unchanged.
429rate_limit_exceeded
rate_limited, LIMIT_DAILY
Wait, then retry. See rate limits.
502 / 503PROVIDER_ERRORThe network side refused or is busy. Nothing was charged. Retry after a minute.
Validation · 422
{
    "success": false,
    "message": "Validation failed.",
    "errors": {
        "to": [
            "The to must be a valid Tanzanian mobile number (e.g. 0712345678 or 255712345678)."
        ]
    }
}
Empty wallet · 402
{
    "success": false,
    "error_code": "INSUFFICIENT_BALANCE",
    "error_message": "Wallet credits are insufficient to send this SMS.",
    "phone": "255712345678",
    "cost": 0
}

Rate limits

  • Per key: 60 requests a minute by default. Over it: 429 rate_limit_exceeded. Ask support if you need more.
  • Daily cap: a key or account can have a daily message limit. Over it: 429.
  • Wrong keys: many failed logins from one address are blocked for a while (429 too_many_attempts).

SMS

Send messages and follow them until they reach the phone.

Send an SMS

POST/v1/sms/sendneeds sms:send

Send one message to one phone number. You are charged one credit per SMS part (up to 160 characters is one part; longer messages are split into parts of 153).

FieldDescription
to stringrequired Phone number, for example 0712345678, 255712345678 or +255712345678.
message stringrequired The text, up to 1,600 characters.
from stringoptional One of your approved sender names (max 11 letters or numbers). Left out: your newest approved name, or the platform default.

status is sent when the network accepted the message. Delivery comes later: follow it in the dashboard under Messages. Keep message_id to find it there.

When the send fails the answer has "success": false with error_code and error_message: 402 INSUFFICIENT_BALANCE, 422 INVALID_PHONE, 422 CONTENT_BLOCKED, 422 RECIPIENT_BLOCKED, 429 LIMIT_DAILY, 502 PROVIDER_ERROR. Failed sends cost nothing. A from that is not yours returns 422 invalid_sender.

A message that needs a review by our team returns 202 with "status": "held"; it is sent, and charged, only after approval.

Request
curl -X POST https://nuntio.africa/api/v1/sms/send \
  -H "X-API-Key: $NUNTIO_KEY" \
  -H "X-API-Secret: $NUNTIO_SECRET" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "0712345678",
    "message": "Habari! Oda yako #1042 iko tayari.",
    "from": "MYSHOP"
}'
$res = nuntio('POST', '/sms/send', [
    'to' => '0712345678',
    'message' => 'Habari! Oda yako #1042 iko tayari.',
    'from' => 'MYSHOP',
]);

print_r($res);
const res = await nuntio('POST', '/sms/send', {
    "to": "0712345678",
    "message": "Habari! Oda yako #1042 iko tayari.",
    "from": "MYSHOP"
});

console.log(res);
res = nuntio("POST", "/sms/send", {
    "to": "0712345678",
    "message": "Habari! Oda yako #1042 iko tayari.",
    "from": "MYSHOP"
})

print(res)
Response · 200 OK
{
    "success": true,
    "message_id": 88213,
    "external_id": "0b6f2c1e-8a43-4d0e-9d55-3f2a7c1e9b10",
    "phone": "255712345678",
    "network": "vodacom",
    "segments": 1,
    "cost": 25,
    "status": "sent",
    "sender_id": "MYSHOP",
    "approved_senders": [
        "MYSHOP"
    ]
}