Skip to main content

Reversals

Reverse Incoming Transactions​

Initiate reversals for Incoming Transactions made within the last 30 days.

POST https://sandbox.kopokopo.com/api/api/v2/reversals
Content-Type: application/json
Accept: application/json
Authorization: Bearer <AccessToken>
User-Agent: "<product>/<product-version> <comment>"
{
"transaction_reference": "5d894b0f-b07e-4304-ab4a-d54b80bc7286",
"reason": "Testing Reversals",
"metadata": {
"name": "Test"
},
"_links": {
"callback_url": "https://callback_to_your_app.your_application.com"
}
}

HTTP Request​

POST https://sandbox.kopokopo.com/api/api/v2/reversals

Request Parameters (JSON)​

ParameterRequiredTypeDescription
transaction_referenceyesStringThe reference of the transaction to be reversed.
reasonyesStringThe reason for initiating the reversal.
metadataNoStringA JSON object containing additional information.
_linksYesJSONA JSON object containing the callback_url where the reversal result will be posted.

HTTP Response​

Successful Response​

Upon a successful request a HTTP Status 201 will be returned and the location HTTP Header will contain the URL of the newly created Reversal Request.

HTTP/1.1 201 Created
Location: https://sandbox.kopokopo.com/api/v2/reversals/247b1bd8-f5a0-4b71-a898-f62f67b8ae1c

Error Response​

This will have a HTTP Status code indicating the error and it might have a json that contains the error code and an error message specifying the error that occurred. Please note that the error response might not be present depending on the type of error that occurred.

If the error json response is present, it will look as follows:

HTTP/1.1 400 Bad Request

\{ "error_code": 400, "error_message": [ "You cannot reverse a transaction in Pending Reversal" ] \}

Process Reversal Request API Result​

POST https://your-callback-url.com/api/v2/reversal_results
Content-Type: application/json
X-KopoKopo-Signature: 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >
{
"data": {
"id": "67b1bb87-b89b-4366-93c9-a2bb6944ec99",
"type": "reversals",
"attributes": {
"status": "Processed",
"created_at": "2025-10-31T16:32:54.952+03:00",
"transaction_reference": "059278a2-8ffe-4f31-b3b4-d6c76770c72f",
"reason": "Testing Reversals",
"reversal_bulk_payment": {
"amount": "400.0",
"status": "Transferred",
"origination_time": "2025-10-31T12:55:18.000+03:00",
"transaction_reference": "ce430292-899b-4543-beb8-4195875dc063"
},
"errors":null,
"metadata": {
"name": "Test"
},
"_links": {
"callback_url": "https://your_callback_url.com/",
"self": "https://sandbox.kopokopo.com/api/v2/reversals/67b1bb87-b89b-4366-93c9-a2bb6944ec99"
}
}
}
}

Unsuccessful Reversal

{
"data": {
"id": "c5486bd6-54c5-4d38-9e8a-e5a3597cd704",
"type": "reversals",
"attributes": {
"status": "Processed",
"created_at": "2025-11-24T13:11:13.255+03:00",
"transaction_reference": "8b275328-3b33-4144-9163-b2badbfb5de3",
"reason": "Testing Reversals",
"reversal_bulk_payment": {
"amount": "1300.0",
"status": "Cancelled",
"origination_time": "2025-11-24T13:01:18.000+03:00",
"transaction_reference":null
},
"errors": ["The balance is insufficient for the transaction"],
"metadata": {
"name": "Test"
},
"_links": {
"callback_url": "https://your_callback_url.com/",
"self": "https://sandbox.kopokopo.com/api/v2/reversals/c5486bd6-54c5-4d38-9e8a-e5a3597cd704"
}
}
}
}

After a Reversal Request is initiated, a Reversal API Result will be posted asynchronously to the call back URL specified in the Reversal Request.

Reversal Result Parameters (JSON)​

Parameters contained in a successful Reversal result;

ParameterRequiredTypeDescription
idYesStringThe ID of the reversal request
typeYesStringThe type of the request (reversals)
statusYesStringStatus of the reversal request
created_atYesDateDate and time the reversal request was created
transaction_referenceYesStringTransaction reference being reversed
reasonYesStringReason for reversal
metadataYesJSONMetadata sent with the reversal request
_linksYesJSONObject containing links to the reversal request
reversal_bulk_paymentYesJSONObject containing the reversal transaction
errorsYesJSONObject containing errors if any

Reversal Bulk Payment JSON

ParameterRequiredTypeDescription
amountYesFloatThe amount reversed
statusYesStringThe status of the bulk payment(Transfered means reversed, Cancelled is failed)
origination_timeYesStringThe transaction timestamp
transaction_referenceYesStringThe M-PESA reference
tip

Remember — if you are also subscribed to the buygoods_transaction_reversed and/or b2b_transaction_reversedwebhooks, the Request Reversal Result will also be sent to that end point.

Query Reversal API Status​

GET https://sandbox.kopokopo.com/api/v2/reversals/d79995cd-0111-e511-80da-0aa34a9b2388
Accept: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
Content-Type: application/json
User-Agent: < product >/< product-version > < comment >
{
"data": {
"id": "3a5ed056-988d-4ea6-824b-67f523939b92",
"type": "reversals",
"attributes": {
"status": "Scheduled",
"created_at": "2025-10-22T14:53:55.930+03:00",
"transaction_reference": "20251016125940",
"reason": "Testing Reversals",
"errors": null,
"metadata": {
"name": "Test"
},
"_links": {
"callback_url": "https://your.callback.url.com/",
"self": "https://sandbox.kopokopo.com/api/v2/reversals/3a5ed056-988d-4ea6-824b-67f523939b92"
}
}
}
}

With an Reversal location url, you can query what the status of the Reversal is. If a corresponding Reversal Result exists, it will be bundled in the payload of the result.

HTTP Request​

GET https://sandbox.kopokopo.com/api/v2/reversals/
Accept: application/json
Authorization: Bearer 0Sn0W6kzNicvoWhDbQcVSKLRUpGjIdlPSEYyrHqrDDoRnQwE7Q
User-Agent: < product >/< product-version > < comment >

Query Parameters​

ParameterRequiredTypeDescription
IDYesStringThe reference / ID of the Reversal to retrieve