Tanzania SMS API

LanguSMS API documentation

Integrate bulk SMS, OTPs, alerts and delivery tracking into your Tanzanian application with a predictable JSON REST API.

Download OpenAPI specification

Introduction

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.

BASEhttps://langusms.co.tz/v1

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.

Keep keys on your server. Anyone holding a key can send messages and spend your credits. Keys can be locked to specific IP addresses when you create them.

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

StatusError codeMeaning
400invalid_jsonThe request body was not valid JSON.
401unauthorizedThe API key is missing, invalid or revoked.
402insufficient_creditsYour balance cannot cover this request. Top up and retry.
403sender_id_not_allowedThe sender ID is not approved on your account.
404not_foundNo such message, contact, group or endpoint.
405method_not_allowedWrong HTTP verb for this endpoint.
409not_cancellableThe message has already left the queue.
422validation_errorA field is missing or malformed; see errors.
429rate_limit_exceededToo many requests this minute.
503service_unavailableThe API is temporarily down for maintenance.

Send a message

POST/v1/messages
ParameterTypeDescription
to *stringRecipient mobile number.
message *stringThe text to send, up to 1600 characters.
sender_idstringAn approved sender ID. Defaults to your account default.
referencestringYour own identifier, echoed back and searchable.
callback_urlstringAn https:// URL for this message's delivery receipt.
scheduled_atstringSend 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

POST/v1/messages/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

GET/v1/messages/{id}

Returns the current state of one message. For the full delivery timeline:

GET/v1/messages/{id}/events
{
  "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

GET/v1/messages
QueryDescription
statusFilter by status, e.g. delivered.
toOnly messages to this number.
referenceMatch your own reference exactly.
sender_idOnly messages from this sender ID.
from_date / to_dateDate range, YYYY-MM-DD.
page / per_pagePagination; up to 200 per page.

Pagination details are returned in a meta object alongside data.

Cancel a scheduled message

POST/v1/messages/{id}/cancel

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

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

GET/v1/sender-ids
POST/v1/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

GET/v1/contacts
POST/v1/contacts
PATCH/v1/contacts/{id}
DELETE/v1/contacts/{id}

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

GET/v1/groups
POST/v1/groups
POST/v1/groups/{id}/contacts

Webhooks

GET/v1/webhooks
POST/v1/webhooks
DELETE/v1/webhooks/{id}

Register an https:// endpoint and we POST every event you subscribe to. The signing secret is returned once, when the endpoint is created.

Events

EventFires when
message.submittedMessage accepted by the network
message.deliveredMessage delivered to the handset
message.failedMessage could not be delivered
campaign.completedCampaign finished sending
credits.lowCredit 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

GET/v1/reports/summary

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

StatusMeaningCharged?
queuedAccepted and about to go upstream.Yes
scheduledHeld until scheduled_at.Reserved
submittedAccepted by the mobile network, awaiting a receipt.Yes
deliveredConfirmed on the handset.Yes
undeliveredThe network could not deliver it.Refunded
rejectedRefused before sending — invalid number, opt-out, or blocked.No
failedThe network refused the submission.Refunded
expiredNo receipt arrived inside the delivery window.Yes
cancelledYou cancelled it before it was sent.Refunded
Ready to build?

Create an account and your first API key is issued instantly.

Get an API key