Skip to content

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
AuthSecret key, plus a request signature made with your payout signing secret. See How to sign a request
Scopetransfers: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
PlatformYour 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 onWhere pockets are available: Kenya. Elsewhere the route does not exist and answers 404
Daily capYour 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 ​

HeaderRequiredValue
AuthorizationYesBearer mkp_…
Idempotency-KeyYes1 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-TypeYesapplication/json
X-Mookh-TimestampYesThe Unix time in seconds, within 300 seconds of MOOKHPay's clock
X-Mookh-SignatureYessha256= and 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). 150000 is KES 1,500
external_referencestringYesYour 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
remarksstringNoWhat 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) and 2945 (reference taken) record nothing. Fix the cause and send again with the same Idempotency-Key, signed afresh.
  • Not confirmed, retry with the same key. A timeout, a dropped connection, or 503 with code 3016 can leave the pay-in recorded but not yet booked: it reads back as processing. Send the same body with the same Idempotency-Key and a fresh signature until you get 200 or 201. 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 the external_reference. The same key and body answer 3060 again, and the transfer reads back as failed. After you top up, send a new pay-in with a new Idempotency-Key and a new external_reference.
  • The same key with a different body (a different account, amount, remarks or external_reference) answers 422 and code 3015.

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.

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 (then with data.reason)Fix the request
4003014IDENTITY_HEADER_REFUSEDThe request carries a session or identity headerRemove the header
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 clockSee How to sign a request. Sign every attempt afresh
4032941API_KEY_SCOPE_REQUIREDThe key lacks transfers:writeAn Owner issues 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
4033022PAYOUT_SIGNING_SECRET_MISSINGYour platform has no payout signing secret yetAn Owner makes one in API Integrations
4042943PLATFORM_ACCOUNT_NOT_FOUNDThe account is unknown, another platform's or malformedCheck the id
4092945PLATFORM_REFERENCE_TAKENAnother pay-in, with another Idempotency-Key, already used this external_reference, even one that failedUse a new reference. If you meant the same pay-in, resend it with its original key
4093061PLATFORM_ACCOUNT_DISCONNECTEDThe person disconnected your platform in MOOKHPayStop paying in. Keep what you owe them in your own records until they connect again
4093063PLATFORM_POCKET_NOT_READYThe pocket is still being opened. MOOKHPay opens it moments after the account is made or linkedRetry in a minute with the same key and body, signed again
4151701INVALID_REQUEST_DATAContent-Type is not application/jsonSend JSON
4223015IDEMPOTENCY_KEY_REUSEDThe key was used with a different bodyUse a new key, or resend the original body
4223060PLATFORM_BALANCE_INSUFFICIENTYour platform's main balance does not hold amount. data.available is your main balance in minor units, when MOOKHPay could read itTop up, then send a new pay-in with a new key and a new reference
4223062PLATFORM_TRANSFER_CAP_REACHEDThe 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 failPay in at most remaining, wait for the next day, or ask MOOKHPay to raise the cap
4223064PLATFORM_POCKET_NOT_SET_UPYour platform has no pocket set upAsk MOOKHPay to set one up
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 or its pocket could not be read, or the ledger did not confirm the pay-inRetry 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.

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