Skip to content

How platforms work ​

A platform is a MOOKHPay organisation that opens and runs accounts for the people it works with. There are two ways to run one:

  • Sellers take payments. Each seller gets a full MOOKHPay account with a wallet, buyers pay the seller, and the platform takes a fee from each payment. A marketplace is the usual case. See Take payments with a fee.
  • You pay into pockets. Customers pay the platform, and the platform pays each person what they've earned into a pocket with its name on it, inside their MOOKHPay wallet. Creator, gig and freelance platforms are the usual case. See Pay into your users' pockets.

A platform with a pocket set up by MOOKHPay works in pockets for every account it reaches ("pocket mode"); one without works the first way.

This page explains the rules every platform route follows. The other platform pages show how to do each job.

Do you need the platform API? ​

Only if you open a MOOKHPay account for each of your sellers. If you take payments for your own business, into your own wallet, you don't: use a hosted checkout or a direct charge with your own secret key, and skip every page in this section. That is true however many people you sell for, as long as the money lands in your wallet and you pay them yourself.

Three words on these pages mean different things:

WordWhat it means
Your accountThe MOOKHPay organisation that owns your secret key. Payments you take for yourself land in its wallet, your main balance. Only two routes touch it: a pay-in moves money from it into a person's pocket, and GET /balance reads it.
PlatformYour organisation, once MOOKHPay staff have switched it on to run accounts for sellers. Your own account works exactly as before.
Seller account (acct_…)A separate MOOKHPay account, with its own wallet, that your platform opened or that a seller linked to it. The API reference calls these "accounts". Every route under /v1/payments/merchant/accounts, and every payout, login link and account link, is about one of them.
PocketIn pocket mode, the part of a seller's wallet that carries your platform's name. Pay-ins land in it and payouts leave from it, and the account routes read only it.

There is no "platform account" to create. Your platform is your existing organisation, and the accounts it runs belong to your sellers.

A platform canA platform cannot
Open a MOOKHPay account for a sellerReach an account it did not open, unless the owner approved a link with their PIN
Take a payment for a seller, with its feeChoose where a seller's payouts go without them: a pocket's payout number is set only with a code texted to that number
Read a seller's balances and movementsChange a seller's split rules or settings
Read every account it reaches in one feedMove money between sellers, or out of a seller's account into yours
Pay out a seller's wallet (or, in pocket mode, its pocket) to the sellerRefund a payment taken through the platform
Pay from its own balance into a seller's pocket
Open MOOKHPay for a seller with a one-time login linkSend money or change anything in the session a login link opens
Ask an existing MOOKHPay user to link their accountSubmit a seller's identity documents
Ask for a business account for a sellerUse one key across countries

How a platform is switched on ​

MOOKHPay staff switch an organisation on as a platform. It is not self-serve. Ask MOOKHPay, and agree three numbers with them: your maximum fee share, your daily payout cap and how many accounts you may open in a day. For pockets, also agree your pocket's name and look, the text people get when it opens, and your daily pay-in cap.

Today the platform routes are on in Kenya, with payouts, account links and pockets. Login links and direct charges are not switched on in production yet, and there are no platform routes in Uganda.

Until your organisation is switched on, or while its platform is suspended, every platform route answers 403 with code 2942.

The platform features are also switched on per deployment. A route whose feature is off is not registered at all, so it answers 404.

Deployment settingRoutes
PLATFORM_API_ENABLEDAccounts, balances, transactions, the all-accounts feed and business account requests. on_behalf_of on checkouts and charges does not read this setting: it needs only a platform switched on for your organisation, a key with payments:write, and an account you reach
PLATFORM_PAYOUTS_ENABLED (with the API on)Payouts and the payout signing secret
PLATFORM_LOGIN_LINKS_ENABLED (with the API on)Login links
PLATFORM_ACCOUNT_LINKS_ENABLED (with the API on)Account links
PLATFORM_POCKETS_ENABLED (with the API on)Pockets: pay-ins, payout numbers and pocket-only reads
DIRECT_CHARGES_ENABLEDDirect charges, with or without a platform

GET /balance is not a platform route and is registered everywhere.

Which accounts you can reach ​

A platform reaches two kinds of account, and nothing else:

  • an account it opened with POST /accounts (its origin is created), and
  • an existing account whose owner approved your account link in MOOKHPay with their PIN (its origin is linked).

No route lets a platform give itself access to anybody else.

Every account route takes your platform's id for the account, acct_<country>_<24 hex>. An id that is unknown, belongs to another platform, has been revoked by its owner, or is not shaped like an account id gets the same answer: 404 with code 2943. The body is identical in every case, so neither you nor anybody holding your key can probe which ids exist.

In pocket mode, an account whose owner disconnected your platform answers 409 with code 3061 (PLATFORM_ACCOUNT_DISCONNECTED) instead, and does not count toward the limit below.

Unknown ids are counted ​

Every 404 on an account id counts against your platform, whichever of its keys made the call. After 100 in an hour (the default; MOOKHPay can set another number for a deployment), every route that looks up an account answers 429 with code 1804 until the hour ends. Retry-After and data.retryAfter give the seconds left.

json
{
  "ok": false,
  "description": "Too many requests, please try again later",
  "data": { "retryAfter": 2417 },
  "code": 1804
}

A loop that retries a stale id will lock out every account lookup for the rest of the hour. Remove an account from your records when you receive account.disconnected.

Key scopes and account grants ​

Two things decide whether a call about an account goes through.

Your key's scopes. A platform uses the same secret key as any merchant, with more scopes. Scopes are fixed when the key is made and cannot be added later: an Owner chooses them on Create A Key or Replace Key in the hub. See API keys and scopes.

ScopeLets the key
accounts:readRead your accounts, their balances and movements, the feed, payouts and business account requests
accounts:writeOpen seller accounts, and ask for business accounts for them
accounts:linkAsk an existing MOOKHPay user to link their account
payments:writeTake payments on behalf of an account, with a platform fee
payouts:writePay out an account's wallet or pocket, read payouts, and set a pocket's payout number
transfers:writePay from your main balance into a person's pocket. Owner-issued, because it moves your own money
login_links:writeMake login links

balance:read, for reading your own main balance, is not a platform scope: any Owner can add it to a key.

Only an Owner of an organisation that is switched on as a platform can be issued a key with these scopes. The hub offers them on Create A Key only to such an Owner. A key missing the scope a route needs answers 403 with code 2941.

The account's grant. Each account also carries the access its owner gave your platform. An account you opened grants accounts:read, accounts:write, payments:write, payouts:write and login_links:write. A linked account grants only what you asked for and the owner approved, from accounts:read, payments:write, payouts:write and login_links:write.

A payout or login link for an account whose grant does not include payouts:write or login_links:write answers 403 with code 3025, even when your key has the scope. Those are the only two grant checks today: reads and payments on behalf of an account check your key's scopes alone.

Allowed IP addresses ​

MOOKHPay can limit your platform routes to a list of IP addresses or ranges. Staff set the list for you. A platform route called from any other address answers 403 with code 3013. Without a list, any address is accepted.

The list does not apply to POST /checkouts or POST /charges without on_behalf_of, since those are not platform routes.

Headers the API refuses ​

Every merchant route refuses a request that carries a session or identity header, such as X-User-ID, X-Username, X-Acting-As, X-Actor-ID, X-Session-Scope, X-Limits-Tier, X-Internal-Secret or X-Gateway-Secret. It answers 400 with code 3014 before anything else is checked. The platform is always the owner of the key; nothing in a request can name another account.

One organisation and key per country ​

Each country is its own deployment, with its own hosts and accounts. A Kenyan key reaches only Kenyan accounts on the Kenyan host, and every account it opens takes a +254 phone number. To run in Kenya and Uganda, you need a platform organisation and a key in each country. See Environments.

Errors every platform route can answer ​

HTTPCodeNameWhenWhat to do
4003014IDENTITY_HEADER_REFUSEDThe request carried an identity headerRemove it
4012781API_KEY_INVALIDMissing, malformed, unknown or revoked keyCheck the key
4032941API_KEY_SCOPE_REQUIREDThe key lacks the route's scopeMake a key with the scope
4032942PLATFORM_NOT_ENABLEDNot a platform, or suspendedAsk MOOKHPay
4033013PLATFORM_IP_NOT_ALLOWEDCalled from an address not on your listCall from a listed address, or ask MOOKHPay to change the list
4033025PLATFORM_GRANT_SCOPE_MISSINGPayouts and login links only: the account's grant lacks payouts:write or login_links:writeAsk the owner to link again with the scope
4042943PLATFORM_ACCOUNT_NOT_FOUNDUnknown, another platform's, revoked or malformed idStop using the id
4093061PLATFORM_ACCOUNT_DISCONNECTEDPocket mode only: the person disconnected your platform. It does not count against the unknown-id limitStop calling for the account until they link again
4291804RATE_LIMIT_EXCEEDEDToo many requests, or too many unknown ids in an hourWait Retry-After seconds
5032782AUTHN_UNAVAILABLEThe key could not be checkedRetry with backoff
5033016PLATFORM_ACCOUNTS_UNAVAILABLEAccounts could not be read right nowRetry with backoff

The full list is in Errors.

The platform pages ​

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