daraja-openapi

API reference / B2C

Send money from your shortcode to a customer

POST/mpesa/b2c/v3/paymentrequest

Checked against the Safaricom sandbox on 1 December 2026

Pays a customer's M-PESA account: salaries, refunds, winnings, loan disbursements. Needs a B2C shortcode and an API initiator. The result arrives later at ResultURL; a timeout at QueueTimeOutURL. OriginatorConversationID is yours: reuse it when retrying so you can match results and avoid paying twice.

In the SDKs

SDKMethod
TypeScriptb2cPayment()
Pythonb2c_payment()
PHPb2cPayment()
Kotlinb2cPayment()
Swiftb2cPayment()

Request

EnvironmentURL
Sandboxhttps://sandbox.safaricom.co.ke/mpesa/b2c/v3/paymentrequest
Productionhttps://api.safaricom.co.ke/mpesa/b2c/v3/paymentrequest

Send the access token as Authorization: Bearer <token>, and the body as JSON.

FieldTypeDescription
OriginatorConversationIDstringRequiredYour unique ID for this payment. Reuse it on retries.
InitiatorNamestringRequiredThe API operator created on the M-PESA org portal. testapi in the sandbox.
SecurityCredentialstringRequiredThe initiator's password encrypted with Safaricom's public certificate (RSA, PKCS #1 v1.5 padding), base64-encoded. The sandbox and production use different certificates.
CommandIDstringRequiredOne of SalaryPayment, BusinessPayment, PromotionPayment.
AmountintegerRequiredWhole shillings. M-PESA's B2C minimum is KES 10. At least 10.
PartyAstringRequiredA paybill or till number. Matches ^[0-9]{5,7}$.
PartyBstringRequiredA Kenyan mobile number in international format without the plus, e.g. 254708374149. Matches ^254(7|1)[0-9]{8}$.
RemarksstringRequired2–100 characters.
QueueTimeOutURLstring (uri)RequiredMatches ^https://.
ResultURLstring (uri)RequiredMatches ^https://.
OccassionstringOptional. Spelled this way by Daraja. Up to 100 characters.

Example request

curl -X POST "https://sandbox.safaricom.co.ke/mpesa/b2c/v3/paymentrequest" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "OriginatorConversationID": "6f2b8c1e-3c1d-4a8e-9a55-0d1bc7a2f001",
  "InitiatorName": "testapi",
  "SecurityCredential": "EsJocK7+NjqZPC3I3EO+TbvS+xVb9TymWwaKABoaZr/Z/n0UysSs..",
  "CommandID": "BusinessPayment",
  "Amount": 100,
  "PartyA": "600996",
  "PartyB": "254708374149",
  "Remarks": "Refund INV-1001",
  "QueueTimeOutURL": "https://example.com/mpesa/b2c/timeout",
  "ResultURL": "https://example.com/mpesa/b2c/result",
  "Occassion": "Refund"
}'

Response

Daraja queued the request. This is not the outcome: that arrives at ResultURL.

FieldTypeDescription
ConversationIDstringRequired
OriginatorConversationIDstringRequired
ResponseCodestringRequired"0" means Daraja queued the request. The outcome comes to ResultURL.
ResponseDescriptionstringRequired

Errors

StatusMeaning
400Daraja 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.
401Daraja 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.
500Daraja 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

{
  "ConversationID": "AG_20261201_2010325b025970fbc403",
  "OriginatorConversationID": "6f2b8c1e-3c1d-4a8e-9a55-0d1bc7a2f001",
  "ResponseCode": "0",
  "ResponseDescription": "Accept the service request successfully."
}

Callbacks

Daraja calls these on your server. They are not signed: confirm with Daraja before you act on one. See handling callbacks.

The result of a B2C, B2B, reversal, status or balance request

Sent to ResultURL from your request.

ResultCode 0 means the request succeeded. Details arrive as key/value pairs in ResultParameters, which is missing when the request failed. Not signed: match it to your request by OriginatorConversationID and ConversationID, and answer HTTP 200.

FieldTypeDescription
ResultobjectRequired
Result.ResultTypeintegerRequired
Result.ResultCodeinteger or stringRequired0 means success. Some APIs send it as a string.
Result.ResultDescstringRequired
Result.OriginatorConversationIDstringRequired
Result.ConversationIDstringRequired
Result.TransactionIDstring
Result.ResultParametersobject
Result.ResultParameters.ResultParameterarray of object or objectOne item or a list, depending on the API.
Result.ResultParameters.ResultParameter[].KeystringRequired
Result.ResultParameters.ResultParameter[].Valuestring or number
Result.ReferenceDataobject
Result.ReferenceData.ReferenceItemarray of object or object
Result.ReferenceData.ReferenceItem[].KeystringRequired
Result.ReferenceData.ReferenceItem[].Valuestring or number

Example body

{
  "Result": {
    "ResultType": 0,
    "ResultCode": 0,
    "ResultDesc": "The service request is processed successfully.",
    "OriginatorConversationID": "6f2b8c1e-3c1d-4a8e-9a55-0d1bc7a2f001",
    "ConversationID": "AG_20261201_2010325b025970fbc403",
    "TransactionID": "TKU3XXXXXX",
    "ResultParameters": {
      "ResultParameter": [
        {
          "Key": "TransactionAmount",
          "Value": 100
        },
        {
          "Key": "TransactionReceipt",
          "Value": "TKU3XXXXXX"
        },
        {
          "Key": "ReceiverPartyPublicName",
          "Value": "254708374149 - John Doe"
        }
      ]
    },
    "ReferenceData": {
      "ReferenceItem": {
        "Key": "QueueTimeoutURL",
        "Value": "https://internalsandbox.safaricom.co.ke/mpesa/b2cresults/v1/submit"
      }
    }
  }
}

The request timed out in M-PESA's queue

Sent to QueueTimeOutURL from your request.

M-PESA could not process the request in time. Its outcome is unknown: check with the Transaction Status query before retrying a payment.

FieldTypeDescription
ResultobjectRequired
Result.ResultTypeintegerRequired
Result.ResultCodeinteger or stringRequired0 means success. Some APIs send it as a string.
Result.ResultDescstringRequired
Result.OriginatorConversationIDstringRequired
Result.ConversationIDstringRequired
Result.TransactionIDstring
Result.ResultParametersobject
Result.ResultParameters.ResultParameterarray of object or objectOne item or a list, depending on the API.
Result.ResultParameters.ResultParameter[].KeystringRequired
Result.ResultParameters.ResultParameter[].Valuestring or number
Result.ReferenceDataobject
Result.ReferenceData.ReferenceItemarray of object or object
Result.ReferenceData.ReferenceItem[].KeystringRequired
Result.ReferenceData.ReferenceItem[].Valuestring or number

View the source of this page

Built by ByteGigs Labs. Apache 2.0. M-PESA, Daraja and Safaricom are trademarks of Safaricom PLC; this project is independent and not endorsed by Safaricom.