Skip to content

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 main wallet.
  • 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
AuthSecret key, plus a request signature made with your payout signing secret. See How to sign a request
Scopepayouts:write on the key, and payouts:write in the account's grant
PlatformYour organisation must be switched on as a platform. Calls must come from an address on your allow-list if MOOKHPay set one
Switched onPer 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 ​

HeaderRequiredValue
AuthorizationYesBearer mkp_…
Idempotency-KeyYes1 to 128 characters. The same key and body return the same payout. It is part of the signature. See Retries
Content-TypeYesapplication/json
X-Mookh-TimestampYesThe Unix time in seconds, as 1 to 12 digits. Within 300 seconds of MOOKHPay's clock, either way
X-Mookh-SignatureYessha256= followed by 64 lowercase hex characters. See How to sign a request

Parameters ​

Path

NameTypeRequiredConstraints
idstringYesOne of your account ids: acct_, the country, _ and 24 hex characters

Body. Unknown fields are refused.

NameTypeRequiredConstraints
amountintegerYesMinor 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
remarksstringNoWhat 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 amount plus the fee, or the call answers 422 with code 2732. Money in the person's main wallet 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: 422 with code 3037 (PLATFORM_COMPANY_ACCOUNTS_OFF). Its owners withdraw in MOOKHPay.
  • While the pocket is still being opened, the call answers 409 with code 3063 (PLATFORM_POCKET_NOT_READY). Retry shortly with the same Idempotency-Key and 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:

RequestPage
POST /accounts/{id}/payoutsThis page
POST /accounts/{id}/transfersCreate a transfer
POST /accounts/{id}/payout-destinationSet a payout destination
POST /accounts/{id}/payout-destination/verifyVerify 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 ) )
PartWhat it is
timestampThe value you send in X-Mookh-Timestamp: the Unix time in seconds
METHODThe HTTP method in capitals: POST
pathThe 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-KeyThe value you send in the Idempotency-Key header
raw body bytesThe 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=, not json=).
  • 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.

InputValue
Secretmps_0123456789abcdefghijklmnopqrstuvwxyzABCDEFG
X-Mookh-Timestamp1763632804
MethodPOST
Path/v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/payouts
Idempotency-Keypayout-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=3fde6af0d5de57352d6c123f3d69eef2a688d1fef6a44d027f175e2434a24371

Example 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, 2702 and 2731. Fix the cause and send again; the same Idempotency-Key can 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 503 from the key or account check: retry with the same Idempotency-Key and 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, amount or remarks) answers 422 and code 3015.

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.

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAThe 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
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove headers such as X-User-ID and X-Acting-As
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4013021PAYOUT_SIGNATURE_INVALIDThe signature is missing, malformed, wrong or already used, or the timestamp is more than 300 seconds from MOOKHPay's clockSign 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
4032941API_KEY_SCOPE_REQUIREDThe key lacks payouts: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
4032942PLATFORM_NOT_ENABLEDYour organisation is not a platform, or its platform is suspendedTalk to MOOKHPay
4033013PLATFORM_IP_NOT_ALLOWEDThe call came from an address not on your platform's allow-listCall from a listed address, or ask MOOKHPay to change the list
4033022PAYOUT_SIGNING_SECRET_MISSINGYour platform has no payout signing secret yetAn Owner makes one in API Integrations
4033025PLATFORM_GRANT_SCOPE_MISSINGThe 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
4042943PLATFORM_ACCOUNT_NOT_FOUNDThe account is unknown, another platform's, revoked or malformedCheck the id. You cannot pay out from a revoked account
4093061PLATFORM_ACCOUNT_DISCONNECTEDWhere pockets are available (Kenya): the person disconnected your platform in MOOKHPayStop paying out. Ask them to connect again
4093063PLATFORM_POCKET_NOT_READYPocket mode: the pocket is still being openedRetry in a minute with the same key and body, signed again
4151701INVALID_REQUEST_DATAContent-Type is not application/jsonSend JSON
4222701RAIL_NOT_AVAILABLEThe payout rail is not available on this hostRetry later; talk to MOOKHPay if it persists
4222702INVALID_AMOUNTamount 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
4222731DISBURSEMENT_DISABLEDPayouts are switched off on this hostRetry later
4222732INSUFFICIENT_BALANCEThe main wallet, or in pocket mode the pocket, does not hold amount plus the payout fee. See FeesPay out less, with a new key
4222751LEDGER_BOOKING_FAILEDThe ledger refused to reserve the payout for another reasonRetry with a new key; talk to MOOKHPay if it repeats
4222947PLATFORM_PAYOUT_CAP_REACHEDThe 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 onesPay out at most remaining, or wait for the next day
4222948PLATFORM_ACCOUNT_LIMIT_REACHEDThe 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 themPay out less with a new key, or wait. The cap stops applying once the seller passes the identity check
4222949PLATFORM_PAYOUT_NO_DESTINATIONThe account has no payout account and no phone. A business account has no phone, so it needs a payout account its owners setAsk the seller to choose a payout account in MOOKHPay
4223037PLATFORM_COMPANY_ACCOUNTS_OFFPocket mode: the account is a company accountIts owners withdraw in MOOKHPay
4223040PLATFORM_PAYOUT_DESTINATION_INVALIDThe 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
4223015IDEMPOTENCY_KEY_REUSEDThe key was used with a different bodyUse a new key, or resend the original body
4232726POCKET_LOCKEDThe seller locked the wallet or pocket the payout comes fromWait until the lock ends, then send with a new key
4291804RATE_LIMIT_EXCEEDEDOver the rate limit below, or your platform reached its limit of unknown account idsWait Retry-After seconds
5032782AUTHN_UNAVAILABLEThe key could not be checkedRetry with the same key and body
5033016PLATFORM_ACCOUNTS_UNAVAILABLEThe account, its pocket or the seller's contact could not be readRetry 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.

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