Appearance
Create a transfer
Pays into a pocket: moves money from your platform's main balance into the pocket your platform opened in a person's MOOKHPay wallet. This is a pay-in. It is one ledger transaction, with no fee, and once it has succeeded the money is the person's.
Pay-ins exist only in pocket mode: your platform needs a pocket set up by MOOKHPay. MOOKHPay tells the person about every pay-in, naming your platform and the pocket. No webhook is sent to you; the answer to this call is the confirmation.
Endpoint
POST /v1/payments/merchant/accounts/{id}/transfers| Auth | Secret key, plus a request signature made with your payout signing secret. See How to sign a request |
| Scope | transfers:write on the key. Only an Owner can issue it, and only to a platform's key, because it moves your own money. The account's grant needs nothing extra |
| Platform | Your organisation must be switched on as a platform, with a pocket set up. Calls must come from an address on your allow-list if MOOKHPay set one |
| Switched on | Where pockets are available: Kenya. Elsewhere the route does not exist and answers 404 |
| Daily cap | Your platform's daily pay-in cap, set by MOOKHPay. It starts at 0, so every pay-in is refused with 3062 until MOOKHPay sets it |
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, unique across your platform's pay-ins. The same key and body return the same transfer. It is part of the signature |
Content-Type | Yes | application/json |
X-Mookh-Timestamp | Yes | The Unix time in seconds, within 300 seconds of MOOKHPay's clock |
X-Mookh-Signature | Yes | sha256= and 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). 150000 is KES 1,500 |
external_reference | string | Yes | Your own id for this pay-in. 1 to 128 printable ASCII characters with no spaces (! to ~). Unique across your platform, including pay-ins that failed |
remarks | string | No | What the pay-in is for. The person sees it on their pocket, so write it for them. 1 to 100 printable ASCII characters (space to ~). Without it, the movement reads Paid in by and your MOOKHPay ID |
There is no currency, pocket or fee field. The pocket is always your platform's pocket in that account.
Example request
The signature covers the timestamp, POST, the path (with /v1/payments/merchant), the Idempotency-Key and the raw body. Each signature works once, so sign every attempt.
sh
ACCOUNT=acct_ke_9c2f41b07e5d38a6c1f0b294
HOST=https://payments-ke-staging.mookhpay.co
URL_PATH="/v1/payments/merchant/accounts/$ACCOUNT/transfers"
KEY=payin-job-7731
BODY='{"amount":150000,"external_reference":"job-7731","remarks":"Payment for the Safari Lager campaign"}'
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";
// One pay-in per reference: the reference is also the Idempotency-Key,
// so a retry can never pay twice. Call again to retry; it re-signs.
export async function payIn(accountId, { amount, reference, remarks }) {
const url = new URL(`${BASE}/accounts/${accountId}/transfers`);
const body = JSON.stringify({ amount, external_reference: reference, remarks });
const idempotencyKey = `payin-${reference}`;
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) {
const name = answer.data?.error ?? "";
throw new Error(`${res.status} ${answer.code} ${name}: ${answer.description}`);
}
return answer.data;
}
const transfer = await payIn("acct_ke_9c2f41b07e5d38a6c1f0b294", {
amount: 150000,
reference: "job-7731",
remarks: "Payment for the Safari Lager campaign",
});
console.log(transfer.transfer_id, transfer.status);The Python and PHP signed_post helpers on Create a payout sign this request too: pass /accounts/{id}/transfers and this body.
Response
201 Created with description Paid into the pocket when the pay-in is made. 200 OK with description Transfer when the same Idempotency-Key and body already made it.
json
{
"ok": true,
"description": "Paid into the pocket",
"data": {
"transfer_id": "tr_ke_5a0c2e9b7d1f43a8b6e2c917",
"account": "acct_ke_9c2f41b07e5d38a6c1f0b294",
"pocket": { "slug": "kazi" },
"amount": 150000,
"currency": "KES",
"status": "succeeded",
"remarks": "Payment for the Safari Lager campaign",
"external_reference": "job-7731",
"created_at": "2026-11-25T08:14:31.000Z"
}
}A successful answer is always succeeded. Check that amount is the amount you sent before you mark the work paid.
Response fields
data is the transfer object.
Retries
- Not recorded, reuse the key. A field error, a bad signature,
2943,3061(disconnected),3063(pocket opening),3064(no pocket),3062(daily cap) and2945(reference taken) record nothing. Fix the cause and send again with the sameIdempotency-Key, signed afresh. - Not confirmed, retry with the same key. A timeout, a dropped connection, or
503with code3016can leave the pay-in recorded but not yet booked: it reads back asprocessing. Send the same body with the sameIdempotency-Keyand a fresh signature until you get200or201. MOOKHPay books it once, never twice. Never use a new key for this: that would be a second pay-in. - Refused after it was recorded.
3060(your main balance is short) is kept with the key and with theexternal_reference. The same key and body answer3060again, and the transfer reads back asfailed. After you top up, send a new pay-in with a newIdempotency-Keyand a newexternal_reference. - The same key with a different body (a different account,
amount,remarksorexternal_reference) answers422and code3015.
Errors
The checks run in this order: identity headers and JSON parsing; the key, its scope and your platform; the body and headers against the schema; the rate limit; the signature; the account; whole currency units; the Idempotency-Key; the pocket; the reference and your daily cap; then the ledger.
The refusals from the pay-in itself carry the code's name in data.error, for example { "error": "PLATFORM_TRANSFER_CAP_REACHED", "cap": 50000000, "used": 49900000, "remaining": 100000 }. Match on code or on data.error.
| 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 (then with data.reason) | Fix the request |
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carries a session or identity header | Remove the header |
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 | See How to sign a request. Sign every attempt afresh |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks transfers:write | An Owner issues 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 |
403 | 3022 | PAYOUT_SIGNING_SECRET_MISSING | Your platform has no payout signing secret yet | An Owner makes one in API Integrations |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | The account is unknown, another platform's or malformed | Check the id |
409 | 2945 | PLATFORM_REFERENCE_TAKEN | Another pay-in, with another Idempotency-Key, already used this external_reference, even one that failed | Use a new reference. If you meant the same pay-in, resend it with its original key |
409 | 3061 | PLATFORM_ACCOUNT_DISCONNECTED | The person disconnected your platform in MOOKHPay | Stop paying in. Keep what you owe them in your own records until they connect again |
409 | 3063 | PLATFORM_POCKET_NOT_READY | The pocket is still being opened. MOOKHPay opens it moments after the account is made or linked | 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 | 3015 | IDEMPOTENCY_KEY_REUSED | The key was used with a different body | Use a new key, or resend the original body |
422 | 3060 | PLATFORM_BALANCE_INSUFFICIENT | Your platform's main balance does not hold amount. data.available is your main balance in minor units, when MOOKHPay could read it | Top up, then send a new pay-in with a new key and a new reference |
422 | 3062 | PLATFORM_TRANSFER_CAP_REACHED | The pay-in would take your platform past its daily pay-in cap (East Africa Time). data has cap, used and remaining, minor units. The cap counts every pay-in today that did not fail | Pay in at most remaining, wait for the next day, or ask MOOKHPay to raise the cap |
422 | 3064 | PLATFORM_POCKET_NOT_SET_UP | Your platform has no pocket set up | Ask MOOKHPay to set one up |
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 or its pocket could not be read, or the ledger did not confirm the pay-in | Retry with the same key and body, signed again |
Rate limit
120 pay-in requests a minute per platform. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds. Unknown account ids also count against your platform: after 100 in an hour, account routes answer 429 until the hour is up.