Appearance
Create a payout
Pays out from one of your accounts to the seller. The money goes to the payout account the seller chose with their PIN in MOOKHPay, or to the seller's own phone when they chose none. There is no field to send it anywhere else.
Where it comes from depends on your platform:
- Without a pocket, the payout comes out of the account's
mainwallet. - In pocket mode (your platform has a pocket set up by MOOKHPay), it comes out of your platform's pocket in the person's wallet, never
main. See Pocket mode.
The payout is reserved and sent to the rail during the call. The wallet or pocket pays amount plus the payout fee; the seller receives amount. See Fees. The answer is 202 with a payout object; payout.paid or payout.failed follows.
Endpoint
POST /v1/payments/merchant/accounts/{id}/payouts| Auth | Secret key, plus a request signature made with your payout signing secret. See How to sign a request |
| Scope | payouts:write on the key, and payouts:write in the account's grant |
| Platform | Your organisation must be switched on as a platform. Calls must come from an address on your allow-list if MOOKHPay set one |
| Switched on | Per deployment (PLATFORM_PAYOUTS_ENABLED). Where it is off, the route does not exist and answers 404 |
The key is checked with authn on every call, with no 60-second cache.
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_… |
Idempotency-Key | Yes | 1 to 128 characters. The same key and body return the same payout. It is part of the signature. See Retries |
Content-Type | Yes | application/json |
X-Mookh-Timestamp | Yes | The Unix time in seconds, as 1 to 12 digits. Within 300 seconds of MOOKHPay's clock, either way |
X-Mookh-Signature | Yes | sha256= followed by 64 lowercase hex characters. See How to sign a request |
Parameters
Path
| Name | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | One of your account ids: acct_, the country, _ and 24 hex characters |
Body. Unknown fields are refused.
| Name | Type | Required | Constraints |
|---|---|---|---|
amount | integer | Yes | Minor units, 1 to 100000000000, and a multiple of 100 (whole currency units). It must also be inside the payout rail's own limits: an M-Pesa payout must be more than KES 10. See Limits |
remarks | string | No | What the payout is for, shown on the seller's statement. 1 to 100 printable ASCII characters (space to ~) |
There is no currency, destination, phone, rail, wallet or fee field.
Pocket mode
When your platform has a pocket set up, every payout you make is a payout from that pocket:
- It comes out of the pocket your platform's connection opened in the person's wallet. The pocket must hold
amountplus the fee, or the call answers422with code2732. Money in the person'smainwallet or their other pockets is never touched. - It goes to the pocket's own payout number, if one is set. You set it with Set a payout destination and Verify a payout destination; the person can also set it in MOOKHPay with their PIN. Without one, it goes to the payout account the person chose for
main, and without that, to their own phone. - A company account cannot be paid out from a pocket:
422with code3037(PLATFORM_COMPANY_ACCOUNTS_OFF). Its owners withdraw in MOOKHPay. - While the pocket is still being opened, the call answers
409with code3063(PLATFORM_POCKET_NOT_READY). Retry shortly with the sameIdempotency-Keyand body, signed again. - A failed payout puts the money back in the pocket.
The request, the signature and the answer are the same as without a pocket. The pocket refusals carry the code's name in data.error, for example { "error": "PLATFORM_POCKET_NOT_READY" }.
Fees
The payout fee is the fee for the payout's rail, as Retrieve fees shows it in payout.<rail>.total. Where no fee is set it is 0. It is taken from the same wallet or pocket on top of amount, so the wallet needs amount plus the fee, and the seller still receives exactly amount. The answer shows the fee as fee and what left the wallet as total. Treat the fee on the answer as final; the quote can change.
To pay out everything a pocket holds, send its balance less payout.<rail>.total.
A payout that fails returns the fee with the amount. Your platform's daily payout cap (2947) counts amount only. See Fees.
How to sign a request
Every request that moves money or changes where it goes is signed with your platform's payout signing secret. The secret is separate from your API key, so a stolen key alone cannot move money. These requests are signed:
| Request | Page |
|---|---|
POST /accounts/{id}/payouts | This page |
POST /accounts/{id}/transfers | Create a transfer |
POST /accounts/{id}/payout-destination | Set a payout destination |
POST /accounts/{id}/payout-destination/verify | Verify a payout destination |
All four use the same secret, the same algorithm and the same replay check.
The secret
An Owner of your organisation makes the secret in the hub, in API Integrations, while acting for the organisation, and confirms with their PIN. It is mps_ followed by 43 base64url characters, and it is shown once. Making it again replaces it: the new secret signs at once, and the one it replaced keeps signing for 24 hours. See Pay out sellers for rotation. With no secret, a signed route answers 403 and code 3022.
The signature
text
message = timestamp + "." + METHOD + "." + path + "." + Idempotency-Key + "." + raw body bytes
X-Mookh-Signature: sha256=hex( HMAC-SHA256( key = whole secret, message ) )| Part | What it is |
|---|---|
timestamp | The value you send in X-Mookh-Timestamp: the Unix time in seconds |
METHOD | The HTTP method in capitals: POST |
path | The request path, starting with /v1/payments/merchant, exactly as it appears in the URL you call, without the host and without any query string. For example /v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts |
Idempotency-Key | The value you send in the Idempotency-Key header |
| raw body bytes | The request body exactly as it goes over the wire |
- The key is the whole secret string,
mps_included, as UTF-8 bytes. - The four parts are each followed by a
., then the body comes straight after the last.. - MOOKHPay signs the bytes it received, not a re-serialised copy. Serialise the body once, sign that string, and send that same string. Do not let your HTTP library serialise the object again (in Python, send
data=, notjson=). - The hex must be lowercase.
Each signature works once
MOOKHPay accepts a signature once, on any signed route. Sending the same signed request again, even byte for byte, answers 401 and code 3021.
So sign every attempt. A retry needs a fresh timestamp and a fresh signature, and keeps the same Idempotency-Key and the same body. The Idempotency-Key is what makes a retry safe; the signature only proves the request is yours.
Test vector
Check your code against these values before you call MOOKHPay. The secret is an example, not a real one.
| Input | Value |
|---|---|
| Secret | mps_0123456789abcdefghijklmnopqrstuvwxyzABCDEFG |
X-Mookh-Timestamp | 1763632804 |
| Method | POST |
| Path | /v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts |
Idempotency-Key | payout-seller-2291-2026-w47 |
| Body | {"amount":500000,"remarks":"Week 47 sales"} |
The message signed is one line:
text
1763632804.POST./v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts.payout-seller-2291-2026-w47.{"amount":500000,"remarks":"Week 47 sales"}and the header is:
text
X-Mookh-Signature: sha256=3fde6af0d5de57352d6c123f3d69eef2a688d1fef6a44d027f175e2434a24371Example request
sh
ACCOUNT=acct_ke_9c2f41b07e5d38a6c1f0b294
HOST=https://payments-ke-staging.mookhpay.co
URL_PATH="/v1/payments/merchant/accounts/$ACCOUNT/payouts"
KEY=payout-seller-2291-2026-w47
BODY='{"amount":500000,"remarks":"Week 47 sales"}'
TS=$(date +%s)
SIG="sha256=$(printf '%s.POST.%s.%s.%s' "$TS" "$URL_PATH" "$KEY" "$BODY" \
| openssl dgst -sha256 -hmac "$MOOKHPAY_PAYOUT_SECRET" -hex \
| sed 's/^.* //')"
curl -X POST "$HOST$URL_PATH" \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY" \
-H "Idempotency-Key: $KEY" \
-H "Content-Type: application/json" \
-H "X-Mookh-Timestamp: $TS" \
-H "X-Mookh-Signature: $SIG" \
--data-binary "$BODY"js
import { createHmac } from "node:crypto";
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
// Sends one signed POST. Call it again to retry: it signs afresh each time.
export async function signedPost(route, payload, idempotencyKey) {
const url = new URL(`${BASE}${route}`);
const body = JSON.stringify(payload);
const timestamp = Math.floor(Date.now() / 1000).toString();
const signature =
"sha256=" +
createHmac("sha256", process.env.MOOKHPAY_PAYOUT_SECRET)
.update(`${timestamp}.POST.${url.pathname}.${idempotencyKey}.`)
.update(body)
.digest("hex");
const res = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}`,
"Idempotency-Key": idempotencyKey,
"Content-Type": "application/json",
"X-Mookh-Timestamp": timestamp,
"X-Mookh-Signature": signature,
},
body,
});
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
return answer.data;
}
const payout = await signedPost(
"/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts",
{ amount: 500000, remarks: "Week 47 sales" },
"payout-seller-2291-2026-w47",
);
console.log(payout.payout_id, payout.status);python
import hashlib
import hmac
import json
import os
import time
from urllib.parse import urlsplit
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def signed_post(route, payload, idempotency_key):
"""Sends one signed POST. Call it again to retry: it signs afresh each time."""
url = f"{BASE}{route}"
raw = json.dumps(payload, separators=(",", ":")).encode("utf-8")
timestamp = str(int(time.time()))
message = f"{timestamp}.POST.{urlsplit(url).path}.{idempotency_key}.".encode("utf-8") + raw
digest = hmac.new(
os.environ["MOOKHPAY_PAYOUT_SECRET"].encode("utf-8"), message, hashlib.sha256
).hexdigest()
res = requests.post(
url,
headers={
"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}",
"Idempotency-Key": idempotency_key,
"Content-Type": "application/json",
"X-Mookh-Timestamp": timestamp,
"X-Mookh-Signature": f"sha256={digest}",
},
data=raw,
timeout=30,
)
answer = res.json()
if not answer["ok"]:
raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
return answer["data"]
payout = signed_post(
"/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts",
{"amount": 500000, "remarks": "Week 47 sales"},
"payout-seller-2291-2026-w47",
)
print(payout["payout_id"], payout["status"])php
<?php
const BASE = 'https://payments-ke-staging.mookhpay.co/v1/payments/merchant';
// Sends one signed POST. Call it again to retry: it signs afresh each time.
function signed_post(string $route, array $payload, string $idempotencyKey): array
{
$url = BASE . $route;
$body = json_encode($payload, JSON_UNESCAPED_SLASHES);
$timestamp = (string) time();
$path = parse_url($url, PHP_URL_PATH);
$signature = 'sha256=' . hash_hmac(
'sha256',
"{$timestamp}.POST.{$path}.{$idempotencyKey}." . $body,
getenv('MOOKHPAY_PAYOUT_SECRET')
);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY'),
'Idempotency-Key: ' . $idempotencyKey,
'Content-Type: application/json',
'X-Mookh-Timestamp: ' . $timestamp,
'X-Mookh-Signature: ' . $signature,
],
]);
$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']}");
}
return $answer['data'];
}
$payout = signed_post(
'/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts',
['amount' => 500000, 'remarks' => 'Week 47 sales'],
'payout-seller-2291-2026-w47'
);
echo $payout['payout_id'], ' ', $payout['status'], PHP_EOL;hash_hmac in PHP and openssl dgst -hmac both return lowercase hex. In curl, --data-binary sends $BODY byte for byte. Don't name the shell variable PATH: that replaces your shell's search path.
The same signedPost helper signs the other three signed routes: pass their route and body.
Response
202 Accepted with description Payout requested when the payout is made. 200 OK with description Payout when the same Idempotency-Key and body already made it; the answer is the payout as it stands now.
json
{
"ok": true,
"description": "Payout requested",
"data": {
"payout_id": "po_ke_6b1f0e9a2c7d48e3a5b2c810",
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"status": "processing",
"amount": 500000,
"fee": 0,
"total": 500000,
"currency": "KES",
"remarks": "Week 47 sales",
"destination": { "rail": "mpesa", "phone_masked": "+254 7•• ••• 678" },
"approval_id": null,
"failure": null,
"created_at": "2026-11-20T10:00:04.000Z"
}
}A company account's payout answers 202 with status awaiting_approval and an approval_id; no money moves until its owners sign it in MOOKHPay. A payout MOOKHPay checks first answers 202 with status held.
Response fields
data is the payout object. After a 202, read Retrieve a payout or wait for payout.paid or payout.failed to learn the outcome.
Retries
- A refusal before the payout is recorded keeps nothing: a field error, a bad signature,
2947(your daily cap),2949(nowhere to pay),3040(the seller's number cannot be paid),3061(disconnected),3063(pocket not ready),3037(company account in pocket mode),2701,2702and2731. Fix the cause and send again; the sameIdempotency-Keycan be reused. - A refusal after the payout is recorded is kept with the key:
2732(balance),2948(the account's daily limit),2726(locked),2751(ledger refused), and a company approval that could not be filed. The same key and body return the same refusal from then on. The refused payout cannot be retrieved or listed. To try again, send a new payout with a new key. - A timeout, a dropped connection, or a
503from the key or account check: retry with the sameIdempotency-Keyand the same body, with a new timestamp and signature. You get the payout that exists, or it is made now. - The same key with a different body (a different account,
amountorremarks) answers422and code3015.
Errors
The checks run in this order: identity headers and JSON parsing; the key, its scope and your platform (including the address allow-list); the body and headers against the schema; the rate limit; the signature; the account and its grant; then the payout itself. A bad signature on an unknown account therefore answers 3021, not 2943.
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | The body is not JSON, a field is missing, unknown or out of range, Idempotency-Key is missing, or amount is not a multiple of 100. (A missing signing header is 401 3021; an unpayable payout number is 422 3040) | Fix the request |
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carries a session or identity header | Remove headers such as X-User-ID and X-Acting-As |
401 | 2781 | API_KEY_INVALID | Missing, malformed, unknown or revoked key | Check the key |
401 | 3021 | PAYOUT_SIGNATURE_INVALID | The signature is missing, malformed, wrong or already used, or the timestamp is more than 300 seconds from MOOKHPay's clock | Sign the timestamp, method, path, Idempotency-Key and the exact body bytes with the whole mps_ secret, sign every attempt afresh, and keep your server clock in sync |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks payouts:write | Issue a key with the scope |
403 | 3042 | API_KEY_IP_NOT_ALLOWED | The account has allowed addresses and the call came from another address | Call from a listed address |
403 | 2942 | PLATFORM_NOT_ENABLED | Your organisation is not a platform, or its platform is suspended | Talk to MOOKHPay |
403 | 3013 | PLATFORM_IP_NOT_ALLOWED | The call came from an address not on your platform's allow-list | Call from a listed address, or ask MOOKHPay to change the list |
403 | 3022 | PAYOUT_SIGNING_SECRET_MISSING | Your platform has no payout signing secret yet | An Owner makes one in API Integrations |
403 | 3025 | PLATFORM_GRANT_SCOPE_MISSING | The account's grant does not include payouts:write (a linked account whose owner did not give it) | Ask the owner to approve a new account link with payouts:write |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | The account is unknown, another platform's, revoked or malformed | Check the id. You cannot pay out from a revoked account |
409 | 3061 | PLATFORM_ACCOUNT_DISCONNECTED | Where pockets are available (Kenya): the person disconnected your platform in MOOKHPay | Stop paying out. Ask them to connect again |
409 | 3063 | PLATFORM_POCKET_NOT_READY | Pocket mode: the pocket is still being opened | Retry in a minute with the same key and body, signed again |
415 | 1701 | INVALID_REQUEST_DATA | Content-Type is not application/json | Send JSON |
422 | 2701 | RAIL_NOT_AVAILABLE | The payout rail is not available on this host | Retry later; talk to MOOKHPay if it persists |
422 | 2702 | INVALID_AMOUNT | amount is outside the payout rail's limits (M-Pesa KES 10.01 to 150,000.00, so at least 1100 in whole units; MTN MoMo UGX 500 to 5,000,000) | Change the amount |
422 | 2731 | DISBURSEMENT_DISABLED | Payouts are switched off on this host | Retry later |
422 | 2732 | INSUFFICIENT_BALANCE | The main wallet, or in pocket mode the pocket, does not hold amount plus the payout fee. See Fees | Pay out less, with a new key |
422 | 2751 | LEDGER_BOOKING_FAILED | The ledger refused to reserve the payout for another reason | Retry with a new key; talk to MOOKHPay if it repeats |
422 | 2947 | PLATFORM_PAYOUT_CAP_REACHED | The payout would take your platform past its daily payout cap (East Africa Time). data is { cap, used, remaining }, minor units. The cap counts payouts paid or on their way, not refused, failed, declined or unapproved ones | Pay out at most remaining, or wait for the next day |
422 | 2948 | PLATFORM_ACCOUNT_LIMIT_REACHED | The payout would pass the daily cap on money out for an unverified account you opened, where MOOKHPay switches that cap on. data is { cap, used, remaining }, minor units, as far as the ledger gave them | Pay out less with a new key, or wait. The cap stops applying once the seller passes the identity check |
422 | 2949 | PLATFORM_PAYOUT_NO_DESTINATION | The account has no payout account and no phone. A business account has no phone, so it needs a payout account its owners set | Ask the seller to choose a payout account in MOOKHPay |
422 | 3037 | PLATFORM_COMPANY_ACCOUNTS_OFF | Pocket mode: the account is a company account | Its owners withdraw in MOOKHPay |
422 | 3040 | PLATFORM_PAYOUT_DESTINATION_INVALID | The payout account the seller chose, or their own phone, is not a number the rail can pay. data is { "source": "payout_account" } or { "source": "phone" } | Only the seller can change it, in MOOKHPay. Tell them which one from data.source. In pocket mode you can also set the pocket's payout number |
422 | 3015 | IDEMPOTENCY_KEY_REUSED | The key was used with a different body | Use a new key, or resend the original body |
423 | 2726 | POCKET_LOCKED | The seller locked the wallet or pocket the payout comes from | Wait until the lock ends, then send with a new key |
429 | 1804 | RATE_LIMIT_EXCEEDED | Over the rate limit below, or your platform reached its limit of unknown account ids | Wait Retry-After seconds |
503 | 2782 | AUTHN_UNAVAILABLE | The key could not be checked | Retry with the same key and body |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | The account, its pocket or the seller's contact could not be read | Retry with the same key and body |
3061, 3063 and 3037 carry the code's name in data.error.
A company account's payout can also be refused while its approval is filed, with 400 1701 or the rail checks 2701, 2702 or 2731. That refusal is kept with the key like the others above, so retry it with a new key.
Rate limit
60 payout requests a minute per platform. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds.
Separately, every unknown account id your platform sends, from any of its keys, counts against it: after 100 in an hour by default, every account route answers 429 and code 1804 until the hour is up. A disconnected account (3061) does not count.