Skip to main content

USSD API Overview

The AfriRoute USSD API lets you build interactive, session-based mobile applications that run on any phone β€” no internet or app install required. USSD is ideal for mobile banking, airtime top-ups, surveys, and agent tools across 50+ African countries. This page introduces the model, endpoints, and how the USSD docs fit together.

πŸ“± How USSD Works​

USSD interactions are session-based. A user dials a shortcode (e.g. *123#), which opens a real-time session. Your application returns a menu, the user replies with a selection, and the session continues until your app ends it or it times out (default 90 seconds).

There are two integration styles:

  1. Server-initiated β€” you push menus with /v1/ussd/send and advance with /v1/ussd/continue.
  2. Callback-driven β€” the user dials your shortcode and AfriRoute forwards each input to your webhook, which replies with the next screen. See Callbacks.

πŸš€ Quick Start​

curl -X POST https://api.afriroute.ai/api/v1/ussd/send \
-H "Authorization: Bearer $AFRIROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "+251911234567",
"shortcode": "*123#",
"message": "Welcome!\n1. Check Balance\n2. Send Money\n0. Exit",
"session_id": "sess_abc123"
}'

πŸ”‘ Authentication​

Authorization: Bearer $AFRIROUTE_API_KEY

Manage keys in the dashboard. Base URL for all endpoints: https://api.afriroute.ai.

πŸ“‘ Endpoints​

MethodPathPurposeReference
POST/v1/ussd/sendStart a session and show the first menuMenus
POST/v1/ussd/continueAdvance the session after user inputSessions
GET/v1/ussd/sessions/{session_id}Retrieve session stateSessions
POST/v1/ussd/sessions/{session_id}/endEnd a sessionSessions

πŸ”„ Session Lifecycle​

StateMeaning
initiatedSession created, first menu shown
activeUser is navigating menus
expiredTimed out due to inactivity
completedEnded by your app or the user

βš™οΈ Key Constraints​

  • Message length: up to 182 characters per screen.
  • Default timeout: 90 seconds (configurable up to 180).
  • Navigation: keep menus shallow; use consistent keys (e.g. 0 home, 00 back).

🌍 Country Coverage​

CountryShortcode FormatOperators
πŸ‡ͺπŸ‡Ή Ethiopia*123#Ethio Telecom
πŸ‡°πŸ‡ͺ Kenya*123#Safaricom, Airtel
πŸ‡³πŸ‡¬ Nigeria*123#MTN, Glo, Airtel, 9mobile
πŸ‡ΏπŸ‡¦ South Africa*120#All major operators
πŸ‡¬πŸ‡­ Ghana*170#MTN, Vodafone, AirtelTigo

View full coverage β†’

🧩 SDK Example​

const afriroute = require('@afriroute/sdk');
const client = new afriroute.Client('$AFRIROUTE_API_KEY');

await client.ussd.send({
phone: '+251911234567',
shortcode: '*123#',
message: 'Welcome!\n1. Balance\n2. Transfer\n0. Exit',
session_id: crypto.randomUUID()
});

πŸ’‘ Best Practices​

  • Keep menus short β€” 182-character screens fill quickly.
  • Persist state per session_id, not per phone number.
  • Handle invalid input gracefully without ending the session.
  • Mind the timeout β€” long PIN entry flows can expire.

Last Updated: May 2026 Β· Need help? Contact Support β†’