Overview
The USSD service provides endpoints for handling interactive USSD sessions and receiving end-of-session status notifications from Africa’s Talking USSD API.GET /ussd/
Check USSD service status.Response
Returns a simple text message.Example Request
Example Response
POST /ussd/session
Handle interactive USSD session requests from Africa’s Talking.Request Body (Form Data)
Unique session ID for the USSD session
USSD code dialed by the user (e.g., *123#)
Phone number of the user
User input concatenated with asterisks (*). Empty string for first request.
Response
Returns a text response starting with either:- CON - Continue session (show menu and wait for input)
- END - End session (show final message)
Example Request (Initial)
Example Response (Initial)
Example Request (User Selected Option 1)
Example Response (Continue)
Example Request (User Selected 1*1)
Example Response (End)
USSD Flow Logic
The implementation demonstrates a multi-level USSD menu:- Empty text - Show main menu
- text = “1” - Show account submenu
- text = “2” - Display phone number and end
- text = “1*1” - Display account number and end
- Other input - Show invalid choice and end
Response Format
- Each response must start with
CONorEND - Use
\nfor new lines in the menu CONresponses keep the session activeENDresponses terminate the session- User selections are concatenated with
*separator
POST /ussd/status
Webhook callback for USSD end-of-session status notifications.Request Body (Form Data)
Timestamp of the session end (e.g., “2025-09-29 12:00:00”)
Unique session ID
USSD code that was dialed
Mobile network code
Phone number of the user
Session status (e.g., “Success”, “Failed”)
Cost of the USSD session (e.g., “KES 0.10”)
Session duration in milliseconds
Number of hops (requests) in the session
Complete user input path (e.g., “1*1”)
Last response sent to the user
Error message (if status is “Failed”)
Response
Returns “OK” with status 200.Example Request
Example Response
Status Values
- Success - Session completed successfully
- Failed - Session failed (check errorMessage field)
- TimedOut - Session timed out
- Cancelled - User cancelled the session
