Skip to content

List charges for a reference ​

Lists the charges you made for one reference, newest first. Use it to find a charge whose create answer you lost, for example after a timeout, whichever account the charge pays.

It lists only charges your key's account made. It is not a general charge list: there is no route that lists charges without a reference, and there is no cursor.

Endpoint ​

GET /v1/payments/merchant/charges?reference={reference}
AuthSecret key, Authorization: Bearer mkp_…
Scopecharges:write
Feature flagRegistered only where direct charges are on

Headers ​

HeaderRequiredValue
AuthorizationYesBearer mkp_test_… or Bearer mkp_live_…

Parameters ​

Query ​

Unknown query parameters are refused with 400 and code 1701.

NameTypeRequiredConstraints and meaning
referencestringYes1 to 64 characters. The reference you sent on create
limitstring of digitsNo1 to 100, default 20. Outside that range: 400, code 1701, limit is 1 to 100

Example request ​

sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/charges?reference=order-8841&limit=5" \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"
js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const query = new URLSearchParams({ reference: "order-8841", limit: "5" });

const res = await fetch(`${BASE}/charges?${query}`, {
  headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const body = await res.json();
if (!body.ok) throw new Error(`${res.status} ${body.code}: ${body.description}`);

const pending = body.data.charges.find((charge) => charge.status === "pending");
console.log(pending ? pending.id : "no pending charge");
python
import os
import requests

BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"

res = requests.get(
    f"{BASE}/charges",
    params={"reference": "order-8841", "limit": "5"},
    headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
    timeout=30,
)
body = res.json()
if not body["ok"]:
    raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")

pending = next((c for c in body["data"]["charges"] if c["status"] == "pending"), None)
print(pending["id"] if pending else "no pending charge")
php
<?php
$base = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
$query = http_build_query(["reference" => "order-8841", "limit" => "5"]);

$ch = curl_init("$base/charges?$query");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if (!$body["ok"]) {
    throw new RuntimeException("$status {$body['code']}: {$body['description']}");
}
foreach ($body["data"]["charges"] as $charge) {
    echo $charge["id"], " ", $charge["status"], PHP_EOL;
}

Response ​

200 OK. An empty list when you made no charge for that reference.

json
{
  "ok": true,
  "description": "Charges",
  "data": {
    "charges": [
      {
        "id": "ch_ke_7e1a4c9b2d5f80e3a6c1b047",
        "status": "pending",
        "test": false,
        "amount": 150000,
        "currency": "KES",
        "fee": 0,
        "net": 150000,
        "reference": "order-8841",
        "description": "A3 print",
        "payment_method": { "type": "mobile_money", "rail": "mpesa", "phone": "+254 7•• ••• 678" },
        "next_action": {
          "type": "await_payer",
          "expires_at": "2026-11-20T09:20:00.000Z",
          "display": "Enter your M-Pesa PIN on your phone"
        },
        "failure": null,
        "receipt_number": null,
        "hosted_url": "https://mookhpay.co/checkout/cs_ke_0b4d2f7a9c1e53b8d6a2e410",
        "metadata": { "till": "4" },
        "expires_at": "2026-11-20T09:20:00.000Z",
        "created_at": "2026-11-20T09:14:00.000Z"
      }
    ]
  }
}

Response fields ​

FieldTypeMeaning
chargesarrayUp to limit charges, newest first, each as Retrieve a charge answers it: brought up to date on the read, with no client_secret

Errors ​

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAreference missing or too long, limit outside 1 to 100, or an unknown parameterFix the query
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove the header
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4032941API_KEY_SCOPE_REQUIREDThe key lacks charges:writeIssue a key with the scope
4033042API_KEY_IP_NOT_ALLOWEDThe account has allowed addresses and the call came from another addressCall from a listed address
4291804RATE_LIMIT_EXCEEDEDOver the rate limitWait Retry-After seconds
5032782AUTHN_UNAVAILABLEKeys cannot be checkedRetry with backoff

Rate limit ​

120 requests a minute per key owner, shared with the other charge reads and the checkout routes. Over it: 429, code 1804, Retry-After in seconds.

Staging documentation. A checkout made with a secret key on staging charges a real phone. See Environments.