LanguSMS API documentation
Integrate bulk SMS, OTPs, alerts and delivery tracking into your Tanzanian application with a predictable JSON REST API.
Download OpenAPI specificationIntroduction
The LanguSMS API is a JSON REST API for sending SMS in Tanzania and tracking delivery. Every endpoint lives under a single base URL and speaks JSON in both directions.
All requests must use HTTPS. Timestamps are ISO 8601 in UTC offset form.
Phone numbers may be sent in local (0712345678) or international
(255712345678) format — both are normalised for you.
Response envelope
Successful responses carry a data object; failures carry an error object.
// Success { "success": true, "data": { ... } } // Failure { "success": false, "error": { "code": "insufficient_credits", "message": "..." } }
Authentication
Authenticate with the API key from your dashboard under API keys. Send it as a bearer token:
Authorization: Bearer sk_live_3f9a1c7e...
The X-Api-Key header is accepted as an alternative.
Rate limits
Accounts are limited to 600 requests per minute by default.
Every response includes X-RateLimit-Limit,
X-RateLimit-Remaining and X-RateLimit-Reset.
Exceeding the limit returns 429 with a Retry-After header.
Errors & status codes
| Status | Error code | Meaning |
|---|---|---|
| 400 | invalid_json | The request body was not valid JSON. |
| 401 | unauthorized | The API key is missing, invalid or revoked. |
| 402 | insufficient_credits | Your balance cannot cover this request. Top up and retry. |
| 403 | sender_id_not_allowed | The sender ID is not approved on your account. |
| 404 | not_found | No such message, contact, group or endpoint. |
| 405 | method_not_allowed | Wrong HTTP verb for this endpoint. |
| 409 | not_cancellable | The message has already left the queue. |
| 422 | validation_error | A field is missing or malformed; see errors. |
| 429 | rate_limit_exceeded | Too many requests this minute. |
| 503 | service_unavailable | The API is temporarily down for maintenance. |
Send a message
| Parameter | Type | Description |
|---|---|---|
| to * | string | Recipient mobile number. |
| message * | string | The text to send, up to 1600 characters. |
| sender_id | string | An approved sender ID. Defaults to your account default. |
| reference | string | Your own identifier, echoed back and searchable. |
| callback_url | string | An https:// URL for this message's delivery receipt. |
| scheduled_at | string | Send later, e.g. 2026-08-12T09:00:00+03:00. |
Send an Idempotency-Key header to make retries safe — a repeat with the
same key returns the original result instead of sending again.
Request
curl -X POST https://langusms.co.tz/v1/messages \ -H "Authorization: Bearer sk_live_..." \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4471-otp" \ -d '{ "to": "0712345678", "message": "Your verification code is 4821.", "sender_id": "ACMELTD", "reference": "order-4471" }'
Response 202 Accepted
{
"success": true,
"data": {
"id": "msg_9f2c41a8b7d0e3f5",
"to": "255712345678",
"sender_id": "ACMELTD",
"status": "submitted",
"parts": 1,
"encoding": "GSM7",
"credits_charged": 1,
"reference": "order-4471",
"created_at": "2026-08-09T14:22:07+03:00"
}
}
Send in bulk
Up to 1,000 recipients per call. Give each entry its own
text, or set one top-level message that every entry inherits.
{
"sender_id": "ACMELTD",
"message": "Our shop is open until 8pm today.",
"messages": [
{ "to": "0712345678" },
{ "to": "0764000111", "message": "Custom text for this one." },
{ "to": "0687112233", "reference": "vip-3" }
]
}
Duplicate numbers, invalid numbers and opted-out recipients are returned as
rejected entries and are not charged. The response summary reports
total, accepted, rejected
and credits_charged.
Retrieve a message
Returns the current state of one message. For the full delivery timeline:
{
"success": true,
"data": {
"message_id": "msg_9f2c41a8b7d0e3f5",
"events": [
{ "status": "submitted", "occurred_at": "2026-08-09T14:22:07+03:00" },
{ "status": "delivered", "detail": "Delivered to handset",
"occurred_at": "2026-08-09T14:22:19+03:00" }
]
}
}
List messages
| Query | Description |
|---|---|
| status | Filter by status, e.g. delivered. |
| to | Only messages to this number. |
| reference | Match your own reference exactly. |
| sender_id | Only messages from this sender ID. |
| from_date / to_date | Date range, YYYY-MM-DD. |
| page / per_page | Pagination; up to 200 per page. |
Pagination details are returned in a meta object alongside data.
Cancel a scheduled message
Works only while the message is still scheduled; the reserved credits are
returned to your balance. Anything already submitted returns 409 not_cancellable.
Check your balance
{
"success": true,
"data": {
"balance": 8420,
"currency": "TZS",
"price_per_credit": 22,
"low_balance": false,
"credits_used_last_30_days": 15230
}
}
Poll this on a schedule, or subscribe to the credits.low webhook instead.
Sender IDs
A sender ID is the name recipients see. Request one with a clear description of what you will send; approval usually takes a business day. Until then your messages go out under the shared sender ID.
{
"sender_id": "ACMELTD",
"use_case": "Order confirmations and delivery updates for our online store.",
"sample_message": "Your order #1234 has shipped and arrives tomorrow."
}
Contacts & groups
Store an address book alongside your messages. Contacts marked as opted out are skipped automatically by every send, including bulk and campaigns.
Create many at once
{
"group_id": "grp_4a1b2c3d",
"contacts": [
{ "phone": "0712345678", "first_name": "Amina" },
{ "phone": "0764000111", "first_name": "Juma",
"attributes": { "plan": "gold" } }
]
}
Groups
Webhooks
Register an https:// endpoint and we POST every event you subscribe to. The signing secret is returned once, when the endpoint is created.
Events
| Event | Fires when |
|---|---|
| message.submitted | Message accepted by the network |
| message.delivered | Message delivered to the handset |
| message.failed | Message could not be delivered |
| campaign.completed | Campaign finished sending |
| credits.low | Credit balance fell below your threshold |
Payload
{
"event": "message.delivered",
"created_at": "2026-08-09T14:22:19+03:00",
"data": {
"id": "msg_9f2c41a8b7d0e3f5",
"to": "255712345678",
"status": "delivered",
"reference": "order-4471",
"credits_charged": 1,
"delivered_at": "2026-08-09T14:22:19+03:00"
}
}
Verifying the signature
Each request carries X-LanguSMS-Signature: t=<unix>,v1=<hex>,
where the hex is HMAC-SHA256("<t>.<raw body>", secret).
// PHP $body = file_get_contents('php://input'); parse_str(strtr($_SERVER['HTTP_X_LANGUSMS_SIGNATURE'], ',', '&'), $parts); if (abs(time() - (int) $parts['t']) > 300) { http_response_code(400); exit; // too old, likely a replay } $expected = hash_hmac('sha256', $parts['t'] . '.' . $body, $secret); if (!hash_equals($expected, $parts['v1'])) { http_response_code(401); exit; } http_response_code(200);
Reply with any 2xx. Anything else is retried after 30s, 2m, 10m, 1h and 6h before the event is abandoned. Endpoints that keep failing are disabled automatically; you can re-enable them from the dashboard.
Reports
Aggregated totals, a daily series and a per-network breakdown. Pass
range=today|last_7|last_30|this_month|last_month, or
range=custom&from=YYYY-MM-DD&to=YYYY-MM-DD.
Message statuses
| Status | Meaning | Charged? |
|---|---|---|
| queued | Accepted and about to go upstream. | Yes |
| scheduled | Held until scheduled_at. | Reserved |
| submitted | Accepted by the mobile network, awaiting a receipt. | Yes |
| delivered | Confirmed on the handset. | Yes |
| undelivered | The network could not deliver it. | Refunded |
| rejected | Refused before sending — invalid number, opt-out, or blocked. | No |
| failed | The network refused the submission. | Refunded |
| expired | No receipt arrived inside the delivery window. | Yes |
| cancelled | You cancelled it before it was sent. | Refunded |
Ready to build?
Create an account and your first API key is issued instantly.