API reference / C2B
Simulate a customer payment (sandbox only)
POST
/mpesa/c2b/v2/simulateChecked against the Safaricom sandbox on 1 December 2026. Sandbox only: not available in production
Makes the sandbox send your confirmation (and validation) callbacks as if a customer had paid. Not available in production.
In the SDKs
| SDK | Method |
|---|---|
| TypeScript | c2bSimulate() |
| Python | c2b_simulate() |
| PHP | c2bSimulate() |
| Kotlin | c2bSimulate() |
| Swift | Through the generated client: daraja.raw.c2bSimulate() |
Request
| Environment | URL |
|---|---|
| Sandbox | https://sandbox.safaricom.co.ke/mpesa/c2b/v2/simulate |
| Production | https://api.safaricom.co.ke/mpesa/c2b/v2/simulate |
Send the access token as Authorization: Bearer <token>, and the body as JSON.
| Field | Type | Description |
|---|---|---|
ShortCode | stringRequired | A paybill or till number. Matches ^[0-9]{5,7}$. |
CommandID | stringRequired | One of CustomerPayBillOnline, CustomerBuyGoodsOnline. |
Amount | integerRequired | At least 1. |
Msisdn | stringRequired | A Kenyan mobile number in international format without the plus, e.g. 254708374149. Matches ^254(7|1)[0-9]{8}$. |
BillRefNumber | string | The account number. Leave out for a till. |
Example request
curl -X POST "https://sandbox.safaricom.co.ke/mpesa/c2b/v2/simulate" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ShortCode": "600984",
"CommandID": "CustomerPayBillOnline",
"Amount": 250,
"Msisdn": "254708374149",
"BillRefNumber": "INV-1001"
}'Response
The simulated payment was accepted.
| Field | Type | Description |
|---|---|---|
OriginatorCoversationID | string | Spelled this way by Daraja. |
ResponseCode | stringRequired | |
ResponseDescription | stringRequired |
Errors
| Status | Meaning |
|---|---|
400 | Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token. |
401 | Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token. |
500 | Daraja rejected the request. An HTTP 401 with "Invalid API call as no apiproduct match found" means your Daraja app does not have this API product enabled: add it to the app on the Daraja portal, then request a new access token. |
See errors and rate limits for what to do with each.
Example response
{
"OriginatorCoversationID": "53e3-4aa8-9fe0-8fb5e4092cdd3405976",
"ResponseCode": "0",
"ResponseDescription": "Accept the service request successfully."
}