Airtel Money Collections: USSD Push with the Airtel Africa Open API
Collect Airtel Money payments with a USSD PIN prompt: OAuth token, country base URLs, payment request, callback, status enquiry, refunds and message signing — with clear notes on what to verify in your portal.
- Provider
- Airtel Money (Airtel Africa Open API)
- Level
- Intermediate
- Stacks
- Node.js (Express), PHP
- Code maturity
- Simplified
- Last verified
- 25 Nov 2026
Introduction
Airtel Money is the mobile-money service of Airtel Africa, available in more than a dozen African countries. Its Open API lets your backend send a USSD push: the customer gets a PIN prompt on their phone, approves, and your server learns the outcome by callback or by a status enquiry.
This guide walks through the collection flow in Node.js (Express) and plain PHP, with the same rules as every payment integration: secrets on the server, amounts from your database, idempotent order updates, and success decided only by Airtel's server-side status.
Warning: Airtel's API reference is behind a login. We verified hosts, countries and signing switches on 2026-11-25, but request/response field names could not be read on a public page. Compare every field with the documentation in your own portal account before going live.
What the collection API does
POST /auth/oauth2/token— exchange your client id and secret for a bearer token.POST /merchant/v1/payments/— send a USSD push asking a subscriber to pay. The response only means the request was accepted.- The customer enters their Airtel Money PIN (or cancels / ignores it).
- Airtel calls your configured callback URL with the final status, and you can ask with
GET /standard/v1/payments/{id}. POST /standard/v1/payments/refund— refund a successful collection.
Every call carries the X-Country and X-Currency headers that select the Airtel operating company ("opco").
Countries and currencies
The central portal's configuration (checked 2026-11-25) lists these country/currency pairs for X-Country / X-Currency:
UG/UGXUganda,KE/KESKenya,TZ/TZSTanzania,RW/RWFRwanda,MG/MGAMadagascar,CD/CDFDR Congo,ZM/ZMWZambia,MW/MWKMalawi,TD/XAFChad,CG/XAFCongo-Brazzaville,NE/XOFNiger,SC/SCRSeychelles, andGAGabon (listed with the codeCFAin the config — confirm the exact currency code for Gabon in your portal).
Airtel also runs per-country developer portals (for example developers.airtelkenya.com, developers.airtel.ug, developers.airtel.co.tz). Onboarding is per country: a merchant account in Kenya does not let you collect in Uganda.
Warning: Nigeria (Airtel's payment service bank) is configured separately and was not checked for this guide.
Payment methods covered
- Collections / USSD push — merchant-initiated payment approved with the customer's PIN. Covered here.
- Refunds — reverse a successful collection to the customer. Covered briefly.
- Disbursements, cash-in, remittance — separate products in the portal; several require an encrypted PIN and extra approval. Not covered.
When to use Airtel Money Collections
- Your customers use Airtel Money (it is a major wallet in Uganda, Zambia, Malawi, DR Congo and several other markets, and an alternative to M-Pesa in Kenya and Tanzania).
- You want a wallet checkout without cards, approved by PIN on the customer's own phone.
- You can complete Airtel's merchant onboarding in each country you serve and host a public HTTPS callback.
When not to use it
- You want one contract for many wallets and countries — an aggregator may be quicker than separate Airtel onboardings per opco.
- You need cards or bank transfers.
- You have no backend: the client secret and token must never be in a browser or app.
- You need a public, stable API reference to code against without signing up — Airtel's reference is login-gated.
Real-world scenarios
- E-commerce in Zambia or Uganda: the customer enters their Airtel number, receives a PIN prompt, and your order page updates when your server confirms the status.
- Kenyan shop offering both M-Pesa and Airtel Money: detect the network from the number prefix and route Airtel numbers to this flow and Safaricom numbers to Daraja.
- Bill or fee payments: use the bill reference as your
referenceand a uniquetransaction.idper attempt.
Registration and onboarding
- Sign up on the developer portal for your country (or the central developers.airtel.africa portal, which links to each country).
- Create an application, add the Collection product and note the client id and client secret for the staging (UAT) environment.
- In the application settings configure your callback URL (the portal has separate UAT and production callback settings) and, where offered, callback authentication and message signing.
- Test in UAT, then submit the go-live request. Airtel's local team completes merchant KYC and issues production credentials.
Warning: Go-live documents, fees and timelines are set per country and are not on any public page we could read. Ask the Airtel Money team in the target country.
Staging (UAT) environment and base URLs
Historically all countries used one pair of hosts: https://openapiuat.airtel.africa (staging) and https://openapi.airtel.africa (production). Both still answered our probes on 2026-11-25.
However, the per-country portals now show this notice (Kenya, deployed 2026-03-15): *"These endpoints are deprecated and will be retired soon. Please migrate to the new base URLs. Staging: https://openapiuat.airtelkenya.com | Production: https://openapi.airtelkenya.com"*. Uganda (openapiuat.airtel.ug / openapi.airtel.ug) and Tanzania (openapiuat.airtel.co.tz / openapi.airtel.co.tz) show the same notice. All of these hosts answered our token probe.
Recommendation: make the base URL a per-country configuration value and use your country's new host.
Test MSISDNs and test PINs for UAT are provided inside the portal's API simulator; we found no public list of test numbers, so none are quoted here.
Warning: Do not hard-code openapi.airtel.africa. It is announced as deprecated on the per-country portals; check which host your country's portal currently shows.
Credentials you need
- Client id + client secret per application and environment — used to get an access token.
- Callback URL registered in the portal (not sent per request in the classic flow).
- Callback authentication private key — if you enable callback authentication, Airtel adds a
hashto callbacks that you verify with this key (details unverified, see the webhooks section). - Airtel's RSA public key — only if message signing or PIN encryption is enabled for your product and country.
Keep all of these on the server only.
Security: The client secret lets anyone collect money into your merchant account's name and query your transactions. Never ship it in a web or mobile app.
Environment configuration
Use one set of variables per country you serve. The example shows Kenya.
# Airtel Money Open API — one block per country
AIRTEL_BASE_URL=https://openapiuat.airtelkenya.com # production: https://openapi.airtelkenya.com
AIRTEL_COUNTRY=KE
AIRTEL_CURRENCY=KES
AIRTEL_CLIENT_ID=replace-me
AIRTEL_CLIENT_SECRET=replace-me
# Only if callback authentication is enabled in the portal
AIRTEL_CALLBACK_PRIVATE_KEY=replace-me
# Random value appended to the callback path you register in the portal
AIRTEL_CALLBACK_TOKEN=replace-with-random-hex
PORT=3000Authentication
POST {base}/auth/oauth2/token with a JSON body { "client_id": "...", "client_secret": "...", "grant_type": "client_credentials" }. The response contains access_token, expires_in and token_type. Cache the token until shortly before it expires.
Our probe on 2026-11-25 confirmed the endpoint and the OAuth error format: wrong credentials return HTTP 400 with {"error":"invalid_client","error_description":"Invalid client authentication"}; an invalid bearer token on API calls returns {"error":"invalid_token", ...}.
// airtel.mjs — shared helpers. One instance per country in multi-country apps.
const BASE = process.env.AIRTEL_BASE_URL;
let cache = { token: null, expiresAt: 0 };
export async function getToken() {
if (cache.token && Date.now() < cache.expiresAt) return cache.token;
const res = await fetch(BASE + "/auth/oauth2/token", {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "*/*" },
body: JSON.stringify({
client_id: process.env.AIRTEL_CLIENT_ID,
client_secret: process.env.AIRTEL_CLIENT_SECRET,
grant_type: "client_credentials",
}),
});
const body = await res.json();
if (!res.ok) throw new Error("Airtel token failed: " + (body.error_description || res.status));
cache = { token: body.access_token, expiresAt: Date.now() + (Number(body.expires_in) - 60) * 1000 };
return cache.token;
}
export async function airtel(method, path, body) {
const res = await fetch(BASE + path, {
method,
headers: {
"Content-Type": "application/json",
Accept: "*/*",
"X-Country": process.env.AIRTEL_COUNTRY,
"X-Currency": process.env.AIRTEL_CURRENCY,
Authorization: "Bearer " + (await getToken()),
},
body: body ? JSON.stringify(body) : undefined,
});
const data = await res.json().catch(() => null);
return { status: res.status, data };
}Backend: payment request, callback, idempotent update
The backend creates a unique transaction id per attempt and stores it on the order before calling Airtel, takes the amount from the order, and changes the order only once, only from PENDING. On a callback it re-reads the status from Airtel before changing anything.
The example uses an in-memory Map; use a database with a unique index on the transaction id and a conditional update in real code.
import "dotenv/config";
import express from "express";
import crypto from "node:crypto";
import { airtel } from "./airtel.mjs";
const app = express();
app.use(express.json({ limit: "50kb" }));
const orders = new Map([["order-3001", { id: "order-3001", amount: 100, status: "PENDING" }]]); // use a DB
app.post("/api/orders/:id/pay", async (req, res) => {
const order = orders.get(req.params.id);
if (!order || order.status !== "PENDING") return res.status(404).json({ error: "Order not payable" });
// Commonly documented: msisdn WITHOUT the country code (e.g. 7XXXXXXXX). Verify for your country.
const msisdn = String(req.body.msisdn || "").replace(/\D/g, "");
if (msisdn.length < 8 || msisdn.length > 12) return res.status(400).json({ error: "Invalid phone number" });
order.txnId = "T" + crypto.randomUUID().replace(/-/g, "").slice(0, 20); // unique per attempt, saved first
const { status, data } = await airtel("POST", "/merchant/v1/payments/", {
reference: order.id,
subscriber: { country: process.env.AIRTEL_COUNTRY, currency: process.env.AIRTEL_CURRENCY, msisdn },
transaction: {
amount: order.amount, // from YOUR order record
country: process.env.AIRTEL_COUNTRY,
currency: process.env.AIRTEL_CURRENCY,
id: order.txnId,
},
});
if (status !== 200 || data?.status?.success !== true) {
return res.status(502).json({ error: data?.status?.message || "Airtel rejected the request" });
}
res.json({ status: "PENDING", message: "Approve the payment with your Airtel Money PIN." });
});
export async function settle(order) {
if (!order || order.status !== "PENDING") return; // idempotent
const { status, data } = await airtel("GET", "/standard/v1/payments/" + encodeURIComponent(order.txnId));
const t = data?.data?.transaction;
if (status !== 200 || !t) return;
if (t.status === "TS") {
order.status = "PAID";
order.airtelMoneyId = t.airtel_money_id;
} else if (t.status === "TF") {
order.status = "FAILED";
} // TIP / TA / anything else: leave PENDING and check again later
}
app.post("/airtel/callback/:token", (req, res) => {
const a = Buffer.from(process.env.AIRTEL_CALLBACK_TOKEN || "");
const b = Buffer.from(req.params.token || "");
if (!a.length || a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.sendStatus(404);
res.sendStatus(200);
const id = req.body?.transaction?.id;
const order = [...orders.values()].find((o) => o.txnId === id);
settle(order).catch((e) => console.error("settle failed", e.message)); // re-check with Airtel
});
app.get("/api/orders/:id", (req, res) => {
const o = orders.get(req.params.id);
return o ? res.json({ id: o.id, status: o.status }) : res.sendStatus(404);
});
app.listen(process.env.PORT || 3000);Warning: Field names (reference, subscriber, transaction, data.transaction.status, airtel_money_id) follow Airtel's collection API as widely published; we could not open the login-gated reference to re-check them on 2026-11-25.
Tip: Amounts are sent in the currency's normal units (for example 100 = KES 100), not cents. Confirm whether your country accepts decimals.
Frontend
There is no Airtel browser SDK for this flow. Your page collects the customer's Airtel number, calls your /api/orders/:id/pay, tells the customer to approve the PIN prompt, and polls your /api/orders/:id until it shows PAID or FAILED — the same pattern as the React component in the M-Pesa STK Push guide.
If you accept several networks, validate the number prefix on the server and show the right instructions ("Check your phone for an Airtel Money prompt").
Security: The frontend never calls Airtel directly and never decides that a payment succeeded.
Initiating a payment (request reference)
POST {base}/merchant/v1/payments/ (note the trailing slash) with headers Authorization: Bearer <token>, X-Country, X-Currency, Content-Type: application/json.
Body (as commonly documented — verify in your portal):
reference— your reference shown to the customer/statement.subscriber—{ country, currency, msisdn };msisdnis usually the number without the country code.transaction—{ amount, country, currency, id };idis your unique transaction id and is what you query later.
A successful response has status.success: true and status.response_code / status.code values; it does not mean the customer paid.
Airtel also publishes a v2 payments endpoint (/merchant/v2/payments/) used together with message signing; it answered our probe but its contract could not be read publicly.
<?php
// Plain PHP 8 example. Load env vars with your framework or getenv().
function airtel_token(): string {
static $token = null, $expires = 0;
if ($token && time() < $expires) return $token;
$res = airtel_http('POST', '/auth/oauth2/token', [
'client_id' => getenv('AIRTEL_CLIENT_ID'),
'client_secret' => getenv('AIRTEL_CLIENT_SECRET'),
'grant_type' => 'client_credentials',
], false);
$token = $res['access_token'] ?? throw new RuntimeException('Airtel token failed');
$expires = time() + (int) $res['expires_in'] - 60; // cache in Redis/APCu in real apps
return $token;
}
function airtel_http(string $method, string $path, ?array $body = null, bool $auth = true): array {
$headers = ['Content-Type: application/json', 'Accept: */*',
'X-Country: ' . getenv('AIRTEL_COUNTRY'), 'X-Currency: ' . getenv('AIRTEL_CURRENCY')];
if ($auth) $headers[] = 'Authorization: Bearer ' . airtel_token();
$ch = curl_init(getenv('AIRTEL_BASE_URL') . $path);
curl_setopt_array($ch, [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30]);
if ($body !== null) curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
$raw = curl_exec($ch);
curl_close($ch);
return json_decode((string) $raw, true) ?? [];
}
// $order comes from YOUR database; never from the request body.
function airtel_request_payment(array $order, string $msisdn, PDO $db): array {
$txnId = 'T' . bin2hex(random_bytes(10));
$db->prepare('UPDATE orders SET airtel_txn_id = ? WHERE id = ? AND status = ?')
->execute([$txnId, $order['id'], 'pending']); // store before calling Airtel
return airtel_http('POST', '/merchant/v1/payments/', [
'reference' => $order['id'],
'subscriber' => ['country' => getenv('AIRTEL_COUNTRY'), 'currency' => getenv('AIRTEL_CURRENCY'),
'msisdn' => preg_replace('/\D/', '', $msisdn)],
'transaction' => ['amount' => $order['amount'], 'country' => getenv('AIRTEL_COUNTRY'),
'currency' => getenv('AIRTEL_CURRENCY'), 'id' => $txnId],
]);
}Confirming the payment
Confirm with GET {base}/standard/v1/payments/{transactionId} (same headers). The response's data.transaction object carries the status and, on success, Airtel's own reference airtel_money_id — store it for support and refunds.
Status codes as commonly documented: TS = success, TF = failed, TIP = in progress, TA = ambiguous (check again later). The portal configuration shows an additional-status feature enabled for UG, CD, ZM, MW, TZ and RW, so expect extra values there: treat any status other than TS and TF as "not final".
Fulfil only when the status is TS and the order is still pending.
Callbacks and their authentication
Airtel sends the final result to the callback URL configured in the portal (separate settings for UAT and production). The commonly documented payload is { "transaction": { "id", "message", "status_code", "airtel_money_id" } }, where status_code is TS or TF.
Callback authentication (optional): when enabled in the portal, the callback is commonly described as including a hash field — an HMAC-SHA256 of the callback content keyed with the private key the portal gives you, base64-encoded. We could not verify the exact string that is signed.
Safe approach regardless of the signature details:
- Protect the callback path with a secret token you add to the URL you register.
- Verify the
hashif you enabled it (example below; adapt to the exact rule in your portal). - Always re-check the status with
GET /standard/v1/payments/{id}before marking an order paid, and update idempotently.
<?php
require __DIR__ . '/airtel_pay.php';
$token = $_GET['token'] ?? '';
if (!hash_equals((string) getenv('AIRTEL_CALLBACK_TOKEN'), $token)) { http_response_code(404); exit; }
$raw = file_get_contents('php://input', false, null, 0, 65536);
$payload = json_decode($raw, true) ?: [];
$txn = $payload['transaction'] ?? [];
// OPTIONAL: callback authentication. The exact message that Airtel signs is NOT verified here;
// confirm it in your portal docs before enforcing. This assumes HMAC-SHA256 over the transaction JSON.
$key = getenv('AIRTEL_CALLBACK_PRIVATE_KEY');
if ($key && isset($payload['hash'])) {
$expected = base64_encode(hash_hmac('sha256', json_encode($txn, JSON_UNESCAPED_SLASHES), $key, true));
if (!hash_equals($expected, (string) $payload['hash'])) {
error_log('Airtel callback hash mismatch; relying on status re-check only');
}
}
http_response_code(200);
echo json_encode(['ok' => true]);
// Never trust the callback body: ask Airtel, then update only a pending order.
$db = new PDO(getenv('DATABASE_DSN'), getenv('DATABASE_USER'), getenv('DATABASE_PASSWORD'));
$status = airtel_http('GET', '/standard/v1/payments/' . rawurlencode((string) ($txn['id'] ?? '')));
$t = $status['data']['transaction'] ?? [];
if (($t['status'] ?? '') === 'TS') {
$db->prepare('UPDATE orders SET status = ?, airtel_money_id = ? WHERE airtel_txn_id = ? AND status = ?')
->execute(['paid', $t['airtel_money_id'] ?? null, $txn['id'], 'pending']);
} elseif (($t['status'] ?? '') === 'TF') {
$db->prepare('UPDATE orders SET status = ? WHERE airtel_txn_id = ? AND status = ?')
->execute(['failed', $txn['id'], 'pending']);
}Security: Because the signature rule could not be verified, the examples never rely on the callback alone: the status enquiry is the source of truth.
Status checks and reconciliation
Run a scheduled job that calls GET /standard/v1/payments/{transactionId} for orders still pending after about a minute, with back-off, and stops after your own expiry window. Use the same settle function as the callback so both paths share one idempotent update.
Callbacks can be missed (deploys, firewalls, TLS problems), and statuses such as TIP or TA can take time to resolve, so the job is required.
Refunds
Commonly documented: POST {base}/standard/v1/payments/refund with body { "transaction": { "airtel_money_id": "<id from the successful payment>" } } and the usual headers. Refunds are full-amount reversals of a successful collection; the result is checked with the status enquiry.
Before refunding: confirm the order is paid, record a refund request in your database first (unique per order), and only then call the API so retries cannot refund twice.
Warning: Refund availability, partial-refund support and time limits could not be verified on a public page. Confirm with your Airtel account manager and the portal reference.
Errors
Verified by probe (2026-11-25):
400 invalid_client— *Invalid client authentication* on/auth/oauth2/token(wrong id/secret, or credentials from another environment or country host).401/403 invalid_token— *The access token is invalid or has expired* on API calls.
Business results come inside the JSON body (status.code, status.message, status.response_code, status.result_code) and, for transactions, in data.transaction.status. Airtel uses response codes of the form DP00800001xxx for collection outcomes (for example insufficient funds, wrong PIN, timeout); the full table is in the portal reference, which we could not open publicly. Log the code and message for every attempt.
Going to production
- Use your country's new production host (for example
https://openapi.airtelkenya.com,https://openapi.airtel.ug,https://openapi.airtel.co.tz) and production client credentials. - Register the production callback URL in the portal; serve it over HTTPS with a valid certificate.
- Ask whether message signing or digital signature is mandatory for your product: the portal configuration enables message signing for some products per country (for example UG on the central portal, CG on the Kenya portal, TZ on the Tanzania portal) and a digital-signature option for Kenya. When enabled, requests carry extra signing headers (commonly
x-signatureandx-key, built with AES and Airtel's RSA public key) — implement them from the portal reference. - Some products (not collections in the classic flow) also need IP whitelisting and an encrypted PIN.
- Run the reconciliation job and alert on stuck pending orders.
Warning: The message-signing algorithm details (exact headers, key sizes, what is encrypted) could not be verified publicly. Do not go live in a country where signing is enabled until you have implemented it from the official reference.
Security checklist
- Client secret, callback key and tokens only on the server.
- Unique transaction id per attempt, stored before the call; unique index in the database.
- Amount and currency from your order record; per-country config for base URL,
X-CountryandX-Currency. - Callback: secret path token, size limit, optional hash check, then a status re-check; idempotent update from pending only.
- Mask MSISDNs in logs; never log tokens or secrets.
- Rate-limit payment initiation per user and per number.
Security: A client-side success screen or a forwarded SMS is never proof of payment. Only a TS status read by your server counts.
Testing
- Get a UAT token with curl to prove your credentials and base URL.
- Use the portal's API simulator and the test numbers/PINs it provides to send a payment and see both success and failure.
- Point the UAT callback URL at an HTTPS tunnel to your machine; send a callback twice and confirm the second one changes nothing.
- Block the callback route, make a payment, and confirm the reconciliation job settles the order.
curl -s -X POST "$AIRTEL_BASE_URL/auth/oauth2/token" \
-H "Content-Type: application/json" -H "Accept: */*" \
-d '{"client_id":"'"$AIRTEL_CLIENT_ID"'","client_secret":"'"$AIRTEL_CLIENT_SECRET"'","grant_type":"client_credentials"}'
# Success: {"access_token":"...","expires_in":...,"token_type":"bearer"}
# Wrong credentials: {"error":"invalid_client","error_description":"Invalid client authentication"}Common mistakes
- Using the deprecated shared host (
openapi.airtel.africa) after your country migrated, or mixing UAT credentials with a production host →invalid_client. - Wrong
X-Country/X-Currencypair (for exampleKEwithUGX). - MSISDN with country code or
+when your country expects the local number. - Reusing
transaction.idacross attempts — use a new id per attempt. - Treating the initiation response as payment — it only means the push was accepted.
- Missing the trailing slash in
/merchant/v1/payments/. - Ignoring message-signing requirements in countries where they are switched on.
- Callback URL not reachable (localhost, plain HTTP, blocked by a WAF or CSRF middleware).
Troubleshooting
invalid_client: check the host matches the environment and country of your credentials and that the body is JSON withgrant_type: client_credentials.invalid_token: token expired or issued by another host; refresh the cache and keep one token cache per country.- Prompt never arrives: the number is not an Airtel Money line, the phone is off, or another USSD session is active. Status will stay in progress, then fail.
- Status stays
TIP/TA: keep polling with back-off; contact Airtel support with the transaction id if it does not resolve. - No callbacks: confirm the callback URL saved in the portal for that environment, HTTPS certificate validity, and firewall rules; rely on the status job meanwhile.
- Signature errors in signing-enabled countries: follow the portal's message-signing reference exactly (key format, AES mode, header names).
Further reading
- Airtel Africa developer portal — links to every country portal.
- Related Metatron guides: MTN MoMo Collections and M-Pesa Daraja STK Push use the same "prompt on phone, confirm on server" pattern.
- If you need Airtel and other wallets through one contract, compare aggregators in Payment Intelligence before building several direct integrations.
Official documentation
- Airtel Africa developer portal
- Documentation (sign-in required for the full API reference)
- Airtel Kenya developer portal
- Airtel Uganda developer portal
Checked 2026-11-25.
Official documentation
Sources
- Airtel Africa developer portal
- Airtel Africa developer documentation (login-gated SPA)
- Airtel Africa portal configuration (countries, signing switches)
- Airtel Kenya portal configuration (base-URL migration notice)
- Airtel Uganda portal configuration (base-URL migration notice)
- Airtel Tanzania portal configuration (base-URL migration notice)
- Airtel UAT token endpoint (probed)
More payment guides
- Airtel Money (Airtel Africa Open API) provider profile
- Adyen Checkout: Sessions flow, Drop-in and HMAC webhooks
- Flutterwave Checkout (Standard): hosted payment page, webhooks, verify and refunds
- M-Pesa Daraja STK Push (Lipa na M-Pesa Online)
- MTN MoMo Collections: Request to Pay with the MoMo Open API
- Mercado Pago Checkout Pro: preferences, back URLs and signed webhooks
- Mollie Payments API: hosted checkout, webhooks and refunds
- PayHero Kenya: M-Pesa STK Push via the PayHero API
- PayPal Checkout with Orders v2, verified webhooks and refunds