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.
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)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.
Three steps, about five minutes.
spk_…) and a secret (sps_…). The secret is shown once: save it now.402 when the wallet is empty.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.
Copy this small file into your project once. It gives you one function that talks to the API, nuntio(), and a ready-made sendSms():
| Function | What 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.
# 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)
Send both headers on every request. The key ID alone is not enough.
| Header | Value |
|---|---|
X-API-Key | Your key ID, starts with spk_. |
X-API-Secret | Your secret, starts with sps_. |
Accept | application/json |
Content-Type | application/json on requests with a body. |
Each key only does what you tick when you create it. A call outside its permissions returns 403 insufficient_scope.
| Permission | Allows |
|---|---|
sms:send | Send SMS. |
X-API-Key: spk_Xk2mP9qLr4TnB7aW
X-API-Secret: sps_…
Accept: application/json
Content-Type: application/json{
"success": false,
"error": "invalid_credentials",
"message": "Invalid or revoked API credentials."
}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.
Success is 2xx with "success": true. Everything else has "success": false and says why. Two shapes exist:
error (a short code) and message (a sentence you can show).error_code (capitals) and error_message.| HTTP | Code | What to do |
|---|---|---|
| 401 | missing_credentialsinvalid_credentials | Check both headers. The key may be revoked or expired. |
| 402 | insufficient_balanceINSUFFICIENT_BALANCE | Top up, then retry. |
| 403 | insufficient_scopeaccount_disabled | Tick the permission on the key, or contact support. |
| 422 | validation, invalid_sender, INVALID_PHONE, CONTENT_BLOCKED | Fix the request. Validation errors list each field under errors. Do not retry unchanged. |
| 429 | rate_limit_exceededrate_limited, LIMIT_DAILY | Wait, then retry. See rate limits. |
| 502 / 503 | PROVIDER_ERROR | The network side refused or is busy. Nothing was charged. Retry after a minute. |
{
"success": false,
"message": "Validation failed.",
"errors": {
"to": [
"The to must be a valid Tanzanian mobile number (e.g. 0712345678 or 255712345678)."
]
}
}{
"success": false,
"error_code": "INSUFFICIENT_BALANCE",
"error_message": "Wallet credits are insufficient to send this SMS.",
"phone": "255712345678",
"cost": 0
}429 rate_limit_exceeded. Ask support if you need more.429.429 too_many_attempts).Send messages and follow them until they reach the phone.
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).
| Field | Description |
|---|---|
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.
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){
"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"
]
}