Appearance
Balances and dashboards
Three routes read money on the accounts you reach. All need accounts:read.
| Route | Answers | Order |
|---|---|---|
GET /accounts/{id}/balance | Every wallet on one account, with its balance, and the total | — |
GET /accounts/{id}/transactions | One wallet's movements, with the balance after each | Oldest first |
GET /transactions | Every movement on every account you reach, in one feed | Newest first |
All amounts are numbers in minor units. The ledger keeps whole currency units, so every amount these routes return is a multiple of 100.
None of these routes can move money, and none shows an account you do not reach.
If your platform works in pockets, the two per-account routes show only your pocket. See Pocket mode. Your platform's own main balance is read with a different route: see Your own balance.
Read one account's balance
An account has a main wallet and may have pockets the seller made in MOOKHPay, each with a slug and a name.
sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/balance \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const account = "acct_ke_9c2f41b07e5d38a6c1f0b294";
const res = await fetch(
`https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/${account}/balance`,
{ 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}`);
console.log(body.data.currency, body.data.total);python
import os
import requests
account = "acct_ke_9c2f41b07e5d38a6c1f0b294"
res = requests.get(
f"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{account}/balance",
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']}")
print(body["data"]["currency"], body["data"]["total"])php
<?php
$account = "acct_ke_9c2f41b07e5d38a6c1f0b294";
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/$account/balance");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
if (!$body["ok"]) {
throw new RuntimeException("{$body['code']}: {$body['description']}");
}
echo $body["data"]["currency"], " ", $body["data"]["total"], "\n";json
{
"ok": true,
"description": "Balance",
"data": {
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"currency": "KES",
"total": 1485000,
"wallets": [
{ "wallet": "main", "name": "Main", "balance": 1350000 },
{ "wallet": "rent", "name": "Rent", "balance": 135000 }
]
}
}total is every wallet added together. Outside pocket mode, a payout from your platform always comes out of main, so main's balance less the payout fee is the most you can pay out; money in the seller's own pockets is theirs to move. In pocket mode a payout comes out of your pocket instead.
A payout that has been sent but not yet confirmed has already left the balance: the ledger reserves it when the payout starts. A failed payout puts it back.
Read one wallet's movements
GET /accounts/{id}/transactions lists one wallet, oldest first, with balance_after on each row.
| Query | Type | Rules |
|---|---|---|
wallet | string | main (the default) or a pocket slug: lower-case letters, digits and -, up to 50 characters. A wallet the account does not have answers 404 with code 3019 |
from | string | ISO 8601 with a time zone. Inclusive |
to | string | ISO 8601 with a time zone. Inclusive. Must be later than from |
limit | integer | 1 to 100. Default 20 |
cursor | string | next_cursor from the previous page |
The cursor is signed and remembers your platform, the account, the wallet and the window. Pass it back alone, or with the same wallet, from and to. A cursor that was edited, belongs to another account, or is sent with a different filter answers 400 with code 3012. next_cursor is null on the last page.
Because the list runs oldest first, new movements are added at the end. The last page answers next_cursor: null, so there is no cursor to resume from. To pick up what is new later, ask again with from set to the created_at of the last row you hold, and skip the rows you already have: from is inclusive, so that row comes back.
sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/transactions?wallet=main&from=2026-11-01T00:00:00%2B03:00&limit=100" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
async function walletMovements(account, wallet, from) {
const rows = [];
let cursor = null;
do {
const url = new URL(
`https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/${account}/transactions`,
);
if (cursor) url.searchParams.set("cursor", cursor);
else {
url.searchParams.set("wallet", wallet);
url.searchParams.set("from", from);
url.searchParams.set("limit", "100");
}
const res = await fetch(url, {
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}`);
rows.push(...body.data.movements);
cursor = body.data.next_cursor;
} while (cursor);
return rows;
}
const rows = await walletMovements("acct_ke_9c2f41b07e5d38a6c1f0b294", "main", "2026-11-01T00:00:00+03:00");
console.log(rows.length, rows.at(-1)?.balance_after);python
import os
import requests
def wallet_movements(account, wallet, start):
rows, cursor = [], None
while True:
params = {"cursor": cursor} if cursor else {"wallet": wallet, "from": start, "limit": 100}
res = requests.get(
f"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{account}/transactions",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
params=params,
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
rows.extend(body["data"]["movements"])
cursor = body["data"]["next_cursor"]
if not cursor:
return rows
rows = wallet_movements("acct_ke_9c2f41b07e5d38a6c1f0b294", "main", "2026-11-01T00:00:00+03:00")
print(len(rows))php
<?php
function walletMovements(string $account, string $wallet, string $from): array {
$rows = [];
$cursor = null;
do {
$query = $cursor !== null
? http_build_query(["cursor" => $cursor])
: http_build_query(["wallet" => $wallet, "from" => $from, "limit" => 100]);
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/$account/transactions?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
if (!$body["ok"]) {
throw new RuntimeException("{$body['code']}: {$body['description']}");
}
array_push($rows, ...$body["data"]["movements"]);
$cursor = $body["data"]["next_cursor"];
} while ($cursor !== null);
return $rows;
}
$rows = walletMovements("acct_ke_9c2f41b07e5d38a6c1f0b294", "main", "2026-11-01T00:00:00+03:00");
echo count($rows), "\n";json
{
"ok": true,
"description": "Transactions",
"data": {
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"wallet": "main",
"movements": [
{
"id": "40921",
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"wallet": "main",
"type": "deposit",
"status": "completed",
"direction": "in",
"amount": 135000,
"description": "",
"balance_after": 1350000,
"created_at": "2026-11-20T09:33:10.000Z"
}
],
"next_cursor": null
}
}| Field | Meaning |
|---|---|
id | The ledger's transaction id, as a string |
type | The ledger's own type: deposit, withdrawal, transfer, fee or adjustment |
status | pending, completed, failed or reversed |
direction | in when the wallet's balance went up, out when it went down |
amount | The size of the movement, always positive |
description | The ledger's text for the movement. Often empty |
balance_after | The wallet's balance after this movement |
created_at | When the ledger booked it |
Read every account in one feed
GET /transactions is one feed across every account you reach, newest first. It is built for a platform dashboard: one call shows what happened across all your sellers.
| Query | Type | Rules |
|---|---|---|
account | string | Only this account's movements. Unknown, another platform's or revoked answers 404 with code 2943 |
from | string | ISO 8601 with a time zone. Inclusive |
to | string | ISO 8601 with a time zone. Exclusive. Must be later than from |
type | string | deposit, withdrawal, transfer, fee or adjustment |
limit | integer | 1 to 100. Default 20 |
cursor | string | next_cursor from the previous page |
Your platform is always the one your key belongs to; no parameter widens the feed. The cursor is signed by the ledger and tied to your platform. An edited cursor, or another platform's, answers 400 with code 3012. Send the same filters with every page.
sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions?limit=100&from=2026-11-20T00:00:00%2B03:00" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const url = new URL("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions");
url.searchParams.set("limit", "100");
url.searchParams.set("from", "2026-11-20T00:00:00+03:00");
const res = await fetch(url, {
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}`);
for (const m of body.data.movements) console.log(m.account, m.direction, m.amount);python
import os
import requests
res = requests.get(
"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
params={"limit": 100, "from": "2026-11-20T00:00:00+03:00"},
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
for m in body["data"]["movements"]:
print(m["account"], m["direction"], m["amount"])php
<?php
$query = http_build_query(["limit" => 100, "from" => "2026-11-20T00:00:00+03:00"]);
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
if (!$body["ok"]) {
throw new RuntimeException("{$body['code']}: {$body['description']}");
}
foreach ($body["data"]["movements"] as $m) {
echo $m["account"], " ", $m["direction"], " ", $m["amount"], "\n";
}json
{
"ok": true,
"description": "Transactions",
"data": {
"movements": [
{
"id": "SM8xK2pQ7a",
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"wallet": "main",
"type": "system_topup",
"status": "completed",
"direction": "in",
"amount": 135000,
"fee": 0,
"description": null,
"counterparty": null,
"source": "checkout",
"rail": "mpesa",
"external_reference": "TKL3H8Q2ZP",
"refunded_amount": 0,
"created_at": "2026-11-20T09:33:10.000Z"
}
],
"next_cursor": "eyJwIjoiNDIi…"
}
}| Field | Meaning |
|---|---|
id | The ledger's receipt reference for the transaction, SM and at least 8 characters: the same form as ledger_reference in a payment webhook. Not the same form as id on the per-wallet route, which is the bare number |
account | Your account id for the account the movement is on |
wallet | main or the pocket's slug |
type | How the movement reads to the account holder: system_topup (money in from outside MOOKHPay, such as a payment by mobile money or card), system_withdrawal (money out to outside, such as a payout), p2p_transfer (to or from another MOOKHPay account, including your platform's fee), internal_transfer (between the account's own wallets) or transfer (the ledger could not tell) |
status | pending, completed, failed or reversed |
direction | in or out for this wallet |
amount | What moved, always positive. On money out it is what the recipient got, without the fee |
fee | The fee the account paid on this movement. 0 on money in |
description | On a transfer, the sender's note; on an adjustment, the ledger's sentence about it. null on every other type, including payments and payouts |
counterparty | The display name of the other side, when there is one |
source | Where the money came from or went: topup, link, checkout, c2b (M-Pesa Pay Bill), send, withdraw, or null |
rail | The rail the money rode on, for example mpesa, momo or card-uc, or null for a movement inside MOOKHPay |
external_reference | The rail's own receipt, such as the M-Pesa receipt number, or null |
refunded_amount | How much of this movement has been refunded so far |
created_at | When the ledger booked it |
The type filter and the type field use different words
?type= takes the ledger's own types: deposit, withdrawal, transfer, fee or adjustment. The type on each feed row is a different set: system_topup, system_withdrawal, p2p_transfer, internal_transfer or transfer. A row returned by ?type=deposit reads system_topup, not deposit. Filter with the first set and read the second.
What the feed shows for each account
| Account | Movements in the feed |
|---|---|
| One you opened | Its whole history |
| One linked to you | Only movements from the moment the owner approved the link |
| A business account you asked for | Its whole history |
| One whose owner revoked your access | None, including those from before. Rows already in a page you hold stay there |
A movement between two of an account's own wallets appears twice, once for each wallet, with opposite direction.
Build a seller dashboard
A dashboard needs three things: what each seller has now, what happened, and to stay up to date without re-reading everything.
- Store movements by
idandaccount. Treat the pair as unique. Your sync will see some rows twice, and a unique key turns that into a no-op. - Back-fill once per account. Page
GET /transactions?account=<id>untilnext_cursorisnull. - Keep up with one feed. Every few minutes, read
GET /transactions?from=<the newest created_at you hold>across all accounts and page until you reach rows you already have.fromis inclusive, so the newest row comes back again; your unique key ignores it. - Show the balance from the balance route. Do not add movements up to get a balance. A
pendingrow can still fail, and a row can bereversedlater. ReadGET /accounts/{id}/balancewhen the seller opens their dashboard, and cache it briefly. - Refresh on webhooks. On
payment.succeeded,payout.paidorpayout.failedwith youraccount, re-read that account's balance and run step 3. - Remove an account on
account.disconnected. Its rows drop out of the feed and every call about it answers404, or in pocket mode409and code3061.
sh
# Step 3: new movements since the last one you stored
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions?limit=100&from=2026-11-20T09:33:10.000Z" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
// store: an object with has(account, id), put(row) and newest() → ISO string or null
export async function syncFeed(store) {
const newest = await store.newest();
let cursor = null;
do {
const url = new URL("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions");
url.searchParams.set("limit", "100");
if (newest) url.searchParams.set("from", newest);
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
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}`);
let fresh = 0;
for (const row of body.data.movements) {
if (await store.has(row.account, row.id)) continue;
await store.put(row);
fresh++;
}
cursor = fresh > 0 ? body.data.next_cursor : null;
} while (cursor);
}python
import os
import requests
def sync_feed(store):
"""store has has(account, id), put(row) and newest() -> ISO string or None."""
newest = store.newest()
cursor = None
while True:
params = {"limit": 100}
if newest:
params["from"] = newest
if cursor:
params["cursor"] = cursor
res = requests.get(
"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
params=params,
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
fresh = 0
for row in body["data"]["movements"]:
if store.has(row["account"], row["id"]):
continue
store.put(row)
fresh += 1
cursor = body["data"]["next_cursor"] if fresh else None
if not cursor:
returnphp
<?php
// $store has has($account, $id), put($row) and newest(): ?string
function syncFeed($store): void {
$newest = $store->newest();
$cursor = null;
do {
$query = http_build_query(array_filter([
"limit" => 100,
"from" => $newest,
"cursor" => $cursor,
]));
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/transactions?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
if (!$body["ok"]) {
throw new RuntimeException("{$body['code']}: {$body['description']}");
}
$fresh = 0;
foreach ($body["data"]["movements"] as $row) {
if ($store->has($row["account"], $row["id"])) continue;
$store->put($row);
$fresh++;
}
$cursor = $fresh > 0 ? $body["data"]["next_cursor"] : null;
} while ($cursor !== null);
}A movement's status can change after you stored it, for example from pending to completed. The feed does not tell you that a row changed. Re-read recent pending rows by asking again with from set before their created_at, and update the stored row by its id and account.
Pocket mode
When MOOKHPay has set up a pocket for your platform, GET /accounts/{id}/balance and GET /accounts/{id}/transactions show your pocket in the person's wallet and nothing else: not main, not the person's other pockets. See Pay into your users' pockets.
The pocket's balance
json
{
"ok": true,
"description": "Balance",
"data": {
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"currency": "KES",
"pocket": { "slug": "kazi", "name": "Kazi Studio" },
"available": 1350000,
"total": 1350000,
"wallets": [
{ "wallet": "kazi", "name": "Kazi Studio", "balance": 1350000 }
]
}
}| Field | Meaning |
|---|---|
pocket | Your pocket's slug and name |
available | What the pocket holds. The most you can pay out is this less the payout fee from GET /fees |
total | The same as available |
wallets | Only the pocket |
The pocket's movements
GET /accounts/{id}/transactions lists the pocket's movements, with these differences from the shape above:
| Pocket mode | |
|---|---|
wallet query | Leave it out, or send your pocket's slug. Any other wallet answers 404 with code 3019 |
| Order | Newest first |
to | Exclusive |
| The answer | Adds pocket: { slug, name } |
| Each movement | id, account, wallet, type, status, direction, amount, currency, description, reference, created_at. No balance_after |
id | The ledger's receipt reference, SM…, as on the all-accounts feed |
type says what the movement was, from your side:
type | direction | Meaning |
|---|---|---|
transfer_in | in | Money into the pocket, such as your pay-in. reference is the pay-in's external_reference |
payout | out | A payout to a phone: yours, or one the person made in MOOKHPay |
payment_out | out | The person spent or sent the money to someone else |
moved_in | in | The person moved money into the pocket from another of their own wallets |
moved_out | out | The person moved money out of the pocket to another of their own wallets |
The person's own moves (moved_in, moved_out) read description: "Moved by you" and reference: null, and never say which of their wallets the money came from or went to.
When the pocket cannot be read
| HTTP | Code | When |
|---|---|---|
409 | 3061 | The person disconnected your platform. Their pocket and the money in it are theirs |
409 | 3063 | The pocket is still being opened, just after the account was made or linked. Retry in a few seconds |
These errors carry the code's name in data.error.
Your own balance
The routes above read your users' accounts. To reconcile your own books, read your platform's own main balance with GET /balance and its movements with GET /balance/transactions. They need a key with balance:read, which only an Owner can add. They are not platform routes: any organisation can use them, and they are on wherever the merchant API is.
json
{
"ok": true,
"description": "Balance",
"data": {
"currency": "KES",
"available": 48250000,
"pockets": 0,
"total": 48250000,
"wallets": [{ "wallet": "main", "name": "Main", "balance": 48250000 }],
"as_of": "2026-11-25T21:00:00.000Z"
}
}| Field | Meaning |
|---|---|
available | Your main wallet: what checkouts pay into, and what pay-ins come out of |
pockets | Your organisation's own pockets added together. Not the pockets you opened in your users' wallets |
total | available plus pockets |
wallets | Each of your own wallets |
as_of | When MOOKHPay read it |
GET /balance/transactions lists one of your own wallets (wallet, main by default), oldest first. The answer is wallet, movements and next_cursor; each movement has id, type, status, direction, amount, description, balance_after and created_at, as on the per-wallet route above. It takes from, to (both inclusive), limit (1 to 100, default 50) and cursor.
A nightly reconciliation:
- Read
GET /balanceand compareavailablewith what your own ledger says you hold at MOOKHPay. - Page
GET /balance/transactions?from=<yesterday's start>and pair each movement with your records: a checkout paid is moneyin; a pay-in is atransferoutwhosedescriptionis the pay-in'sremarks(or "Paid in by" and your username). - Investigate anything left unpaired before money moves again.
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | limit outside 1 to 100, to not later than from, a bad date or an unknown parameter | Fix the query |
400 | 3012 | PLATFORM_CURSOR_INVALID | An edited cursor, another platform's or account's, or one sent with different filters | Start again without a cursor |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | The account is unknown, another platform's or revoked | Stop using the id |
404 | 3019 | PLATFORM_WALLET_NOT_FOUND | The account has no wallet by that slug | Read the balance for the list of wallets |
409 | 3061 | PLATFORM_ACCOUNT_DISCONNECTED | Pocket mode. The person disconnected your platform | Stop reading the account |
409 | 3063 | PLATFORM_POCKET_NOT_READY | Pocket mode. The pocket is still being opened | Retry in a few seconds |
503 | 2752 | LEDGER_UNAVAILABLE | The ledger did not answer | Retry with backoff |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | Your accounts could not be matched to movements | Retry with backoff |
503 | 3020 | PLATFORM_FEED_UNAVAILABLE | The deployment's ledger does not have the feed switched on | Retry later, or use the per-wallet route |
These routes share one rate limit with the other account routes: 120 requests a minute per platform, across all its keys.