Appearance
Retrieve fees
Reads what MOOKHPay charges on this host for money in and out: the payout fee for each rail, the mobile-money top-up fee, and the card fee. It is the same quote the MOOKHPay app shows people.
Use it before a payout, to show the fee before the person confirms, and to offer "withdraw everything": a pocket can pay out at most its balance less payout.<rail>.total. The fee on the payout itself is final; this is a quote.
Endpoint
GET /v1/payments/merchant/fees| Auth | Secret key, Authorization: Bearer mkp_… |
| Scope | Any one of accounts:read, payouts:write or transfers:write |
| Platform | The key's organisation must be an active platform, and the call must come from an address on its allow-list if it has one |
| Switched on | Registered only where the platform API is on |
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_test_… or Bearer mkp_live_… |
There are no parameters.
Example request
sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/fees \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
const account = "acct_ke_9c2f41b07e5d38a6c1f0b294";
const headers = { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` };
const [fees, balance] = await Promise.all(
[`${BASE}/fees`, `${BASE}/accounts/${account}/balance`].map(async (url) => {
const res = await fetch(url, { headers });
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
return answer.data;
}),
);
// The most this pocket can pay out to M-Pesa, in whole currency units.
const fee = Number(fees.payout.mpesa.total);
const most = Math.floor(Math.max(0, balance.available - fee) / 100) * 100;
console.log(`Withdraw up to ${fees.currency} ${(most / 100).toFixed(2)}, fee ${fee / 100}`);Response
200 OK with description Fees.
json
{
"ok": true,
"description": "Fees",
"data": {
"currency": "KES",
"payout": {
"mpesa": { "rail_fee": "0", "mookhpay_fee": "0", "total": "0" }
},
"topup": {
"mpesa": { "rail_fee": "0", "mookhpay_fee": "0", "total": "0" }
},
"card": { "KES": "0" }
}
}Response fields
Every amount is a string of minor units. Every fee is "0" where none is set.
| Field | Type | Meaning |
|---|---|---|
currency | string | The host's wallet currency: KES in Kenya |
payout | object | One entry per payout rail this host runs, keyed by rail (mpesa in Kenya) |
payout.<rail>.rail_fee | string | What the rail charges for a payout |
payout.<rail>.mookhpay_fee | string | What MOOKHPay adds |
payout.<rail>.total | string | rail_fee plus mookhpay_fee. What a payout to a phone on this rail costs on top of amount, from the same wallet or pocket |
topup | object | One entry per mobile-money rail this host collects on, with the same three fields. What a person adds when they top up their own wallet by mobile money in MOOKHPay. mookhpay_fee is always "0" |
card | object | The card fee per currency, keyed by currency code, added on top when someone pays by card. Empty where card payments are off |
A pay-in (Create a transfer) has no fee and is not listed.
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
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 |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key has none of accounts:read, payouts:write and transfers:write | Use your platform key |
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 | The organisation is not an active platform | Ask MOOKHPay |
403 | 3013 | PLATFORM_IP_NOT_ALLOWED | The call came from an address not on your allow-list | Call from a listed address |
429 | 1804 | RATE_LIMIT_EXCEEDED | Over the rate limit below | Wait Retry-After seconds |
503 | 2782 | AUTHN_UNAVAILABLE | Keys cannot be checked | Retry with backoff |
Rate limit
120 requests a minute per platform, or the higher number MOOKHPay set for it. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds. The fees change rarely: read them once a few minutes and cache them.