Appearance
List refunds
Lists the refunds on your account, newest first, including those asked for in the hub. Filter by status, or by the checkout or charge they refund.
Endpoint
GET /v1/payments/merchant/refunds| Auth | Secret key |
| Scope | refunds:write |
| Switched on | Per deployment (REFUND_API_ENABLED). Where it is off, the route answers 404 |
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_… |
Parameters
Query. Unknown parameters are refused. The filters combine.
| Name | Type | Required | Constraints |
|---|---|---|---|
status | string | No | One or more of requested, approved, refunded and declined, comma separated |
checkout_id | string | No | Only refunds of this checkout |
charge_id | string | No | Only refunds of this direct charge |
limit | integer | No | 1 to 100. Default 20 |
starting_after | string | No | The last id of the previous page, with the same filters |
To page through every refund, pass the last id of each page as starting_after until has_more is false. Refunds made while you page appear at the top and are not in the pages that follow. See Pagination.
Example request
sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/refunds?checkout_id=cs_ke_3f9a1c7e5b2d4a8e6c0b91d7" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
export async function allRefunds(filters = {}) {
const refunds = [];
let after;
for (;;) {
const query = new URLSearchParams({ ...filters, limit: "100" });
if (after) query.set("starting_after", after);
const res = await fetch(`${BASE}/refunds?${query}`, {
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
refunds.push(...answer.data.refunds);
if (!answer.data.has_more) return refunds;
after = answer.data.refunds.at(-1).id;
}
}
console.log(await allRefunds({ status: "requested" }));python
import os
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def all_refunds(**filters):
refunds, after = [], None
while True:
params = {**filters, "limit": 100}
if after:
params["starting_after"] = after
res = requests.get(
f"{BASE}/refunds",
params=params,
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=15,
)
answer = res.json()
if not answer["ok"]:
raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
refunds.extend(answer["data"]["refunds"])
if not answer["data"]["has_more"]:
return refunds
after = answer["data"]["refunds"][-1]["id"]
print(all_refunds(status="requested"))php
<?php
function all_refunds(array $filters = []): array
{
$base = 'https://payments-ke-staging.mookhpay.co/v1/payments/merchant';
$refunds = [];
$after = null;
while (true) {
$query = $filters + ['limit' => 100];
if ($after !== null) {
$query['starting_after'] = $after;
}
$ch = curl_init("$base/refunds?" . http_build_query($query));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (!$answer['ok']) {
throw new RuntimeException("$status {$answer['code']}: {$answer['description']}");
}
array_push($refunds, ...$answer['data']['refunds']);
if (!$answer['data']['has_more']) {
return $refunds;
}
$after = end($answer['data']['refunds'])['id'];
}
}
print_r(all_refunds(['status' => 'requested']));Response
200 OK with description Refunds.
json
{
"ok": true,
"description": "Refunds",
"data": {
"refunds": [
{
"id": "rf_5b1e8c2d7a4f90b3e6a1c2d8",
"status": "refunded",
"amount": 50000,
"fee": 0,
"currency": "KES",
"reason": "One latte was not served",
"decline_reason": null,
"checkout_id": "cs_ke_3f9a1c7e5b2d4a8e6c0b91d7",
"charge_id": null,
"intent_id": "pi_8c1e4f0a7b3d92e5a6f01c48",
"reference": "order-1042",
"provider_receipt": "UAB3K9L2MP",
"method": "mobile",
"requested_via": "app",
"requested_at": "2026-11-21T07:40:12.000Z",
"reviewed_at": "2026-11-21T07:58:30.000Z",
"refunded_at": "2026-11-21T08:00:00.000Z"
}
],
"has_more": false
}
}Response fields
| Field | Type | Meaning |
|---|---|---|
refunds | array | Up to limit refund objects, newest first |
has_more | boolean | true when there is at least one more refund after the last one here |
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | An unknown query parameter, a status with a value that is not one of the four, or limit outside 1 to 100 (limit is 1 to 100) | Fix the query |
400 | 3012 | PLATFORM_CURSOR_INVALID | starting_after is not one of your refunds | Use an id from the previous page |
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carries a session or identity header | Remove it |
401 | 2781 | API_KEY_INVALID | Missing, malformed, unknown or revoked key | Check the key |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks refunds:write | Have an Owner replace the key with one that has it |
403 | 3042 | API_KEY_IP_NOT_ALLOWED | The account has allowed addresses and the call came from another address | Call from a listed address |
429 | 1804 | RATE_LIMIT_EXCEEDED | Over the rate limit below | Wait Retry-After seconds |
503 | 2782 | AUTHN_UNAVAILABLE | The key could not be checked | Retry |
Rate limit
120 requests a minute per account, shared by the three refund routes. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds.