Skip to content

Balances and dashboards ​

Three routes read money on the accounts you reach. All need accounts:read.

RouteAnswersOrder
GET /accounts/{id}/balanceEvery wallet on one account, with its balance, and the total—
GET /accounts/{id}/transactionsOne wallet's movements, with the balance after eachOldest first
GET /transactionsEvery movement on every account you reach, in one feedNewest 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.

QueryTypeRules
walletstringmain (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
fromstringISO 8601 with a time zone. Inclusive
tostringISO 8601 with a time zone. Inclusive. Must be later than from
limitinteger1 to 100. Default 20
cursorstringnext_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
  }
}
FieldMeaning
idThe ledger's transaction id, as a string
typeThe ledger's own type: deposit, withdrawal, transfer, fee or adjustment
statuspending, completed, failed or reversed
directionin when the wallet's balance went up, out when it went down
amountThe size of the movement, always positive
descriptionThe ledger's text for the movement. Often empty
balance_afterThe wallet's balance after this movement
created_atWhen 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.

QueryTypeRules
accountstringOnly this account's movements. Unknown, another platform's or revoked answers 404 with code 2943
fromstringISO 8601 with a time zone. Inclusive
tostringISO 8601 with a time zone. Exclusive. Must be later than from
typestringdeposit, withdrawal, transfer, fee or adjustment
limitinteger1 to 100. Default 20
cursorstringnext_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…"
  }
}
FieldMeaning
idThe 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
accountYour account id for the account the movement is on
walletmain or the pocket's slug
typeHow 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)
statuspending, completed, failed or reversed
directionin or out for this wallet
amountWhat moved, always positive. On money out it is what the recipient got, without the fee
feeThe fee the account paid on this movement. 0 on money in
descriptionOn a transfer, the sender's note; on an adjustment, the ledger's sentence about it. null on every other type, including payments and payouts
counterpartyThe display name of the other side, when there is one
sourceWhere the money came from or went: topup, link, checkout, c2b (M-Pesa Pay Bill), send, withdraw, or null
railThe rail the money rode on, for example mpesa, momo or card-uc, or null for a movement inside MOOKHPay
external_referenceThe rail's own receipt, such as the M-Pesa receipt number, or null
refunded_amountHow much of this movement has been refunded so far
created_atWhen 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 ​

AccountMovements in the feed
One you openedIts whole history
One linked to youOnly movements from the moment the owner approved the link
A business account you asked forIts whole history
One whose owner revoked your accessNone, 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.

  1. Store movements by id and account. Treat the pair as unique. Your sync will see some rows twice, and a unique key turns that into a no-op.
  2. Back-fill once per account. Page GET /transactions?account=<id> until next_cursor is null.
  3. 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. from is inclusive, so the newest row comes back again; your unique key ignores it.
  4. Show the balance from the balance route. Do not add movements up to get a balance. A pending row can still fail, and a row can be reversed later. Read GET /accounts/{id}/balance when the seller opens their dashboard, and cache it briefly.
  5. Refresh on webhooks. On payment.succeeded, payout.paid or payout.failed with your account, re-read that account's balance and run step 3.
  6. Remove an account on account.disconnected. Its rows drop out of the feed and every call about it answers 404, or in pocket mode 409 and code 3061.
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:
            return
php
<?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 }
    ]
  }
}
FieldMeaning
pocketYour pocket's slug and name
availableWhat the pocket holds. The most you can pay out is this less the payout fee from GET /fees
totalThe same as available
walletsOnly 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 queryLeave it out, or send your pocket's slug. Any other wallet answers 404 with code 3019
OrderNewest first
toExclusive
The answerAdds pocket: { slug, name }
Each movementid, account, wallet, type, status, direction, amount, currency, description, reference, created_at. No balance_after
idThe ledger's receipt reference, SM…, as on the all-accounts feed

type says what the movement was, from your side:

typedirectionMeaning
transfer_ininMoney into the pocket, such as your pay-in. reference is the pay-in's external_reference
payoutoutA payout to a phone: yours, or one the person made in MOOKHPay
payment_outoutThe person spent or sent the money to someone else
moved_ininThe person moved money into the pocket from another of their own wallets
moved_outoutThe 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 ​

HTTPCodeWhen
4093061The person disconnected your platform. Their pocket and the money in it are theirs
4093063The 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"
  }
}
FieldMeaning
availableYour main wallet: what checkouts pay into, and what pay-ins come out of
pocketsYour organisation's own pockets added together. Not the pockets you opened in your users' wallets
totalavailable plus pockets
walletsEach of your own wallets
as_ofWhen 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:

  1. Read GET /balance and compare available with what your own ledger says you hold at MOOKHPay.
  2. Page GET /balance/transactions?from=<yesterday's start> and pair each movement with your records: a checkout paid is money in; a pay-in is a transfer out whose description is the pay-in's remarks (or "Paid in by" and your username).
  3. Investigate anything left unpaired before money moves again.

Errors ​

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAlimit outside 1 to 100, to not later than from, a bad date or an unknown parameterFix the query
4003012PLATFORM_CURSOR_INVALIDAn edited cursor, another platform's or account's, or one sent with different filtersStart again without a cursor
4042943PLATFORM_ACCOUNT_NOT_FOUNDThe account is unknown, another platform's or revokedStop using the id
4043019PLATFORM_WALLET_NOT_FOUNDThe account has no wallet by that slugRead the balance for the list of wallets
4093061PLATFORM_ACCOUNT_DISCONNECTEDPocket mode. The person disconnected your platformStop reading the account
4093063PLATFORM_POCKET_NOT_READYPocket mode. The pocket is still being openedRetry in a few seconds
5032752LEDGER_UNAVAILABLEThe ledger did not answerRetry with backoff
5033016PLATFORM_ACCOUNTS_UNAVAILABLEYour accounts could not be matched to movementsRetry with backoff
5033020PLATFORM_FEED_UNAVAILABLEThe deployment's ledger does not have the feed switched onRetry 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.

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