Appearance
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:
| Word | What it means |
|---|---|
| Your account | The 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. |
| Platform | Your 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. |
| In 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 can | A platform cannot |
|---|---|
| Open a MOOKHPay account for a seller | Reach an account it did not open, unless the owner approved a link with their PIN |
| Take a payment for a seller, with its fee | Choose 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 movements | Change a seller's split rules or settings |
| Read every account it reaches in one feed | Move 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 seller | Refund 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 link | Send money or change anything in the session a login link opens |
| Ask an existing MOOKHPay user to link their account | Submit a seller's identity documents |
| Ask for a business account for a seller | Use 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 setting | Routes |
|---|---|
PLATFORM_API_ENABLED | Accounts, 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_ENABLED | Direct 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(itsoriginiscreated), and - an existing account whose owner approved your account link in MOOKHPay with their PIN (its
originislinked).
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.
| Scope | Lets the key |
|---|---|
accounts:read | Read your accounts, their balances and movements, the feed, payouts and business account requests |
accounts:write | Open seller accounts, and ask for business accounts for them |
accounts:link | Ask an existing MOOKHPay user to link their account |
payments:write | Take payments on behalf of an account, with a platform fee |
payouts:write | Pay out an account's wallet or pocket, read payouts, and set a pocket's payout number |
transfers:write | Pay from your main balance into a person's pocket. Owner-issued, because it moves your own money |
login_links:write | Make 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
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carried an identity header | Remove it |
401 | 2781 | API_KEY_INVALID | Missing, malformed, unknown or revoked key | Check the key |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks the route's scope | Make a key with the scope |
403 | 2942 | PLATFORM_NOT_ENABLED | Not a platform, or suspended | Ask MOOKHPay |
403 | 3013 | PLATFORM_IP_NOT_ALLOWED | Called from an address not on your list | Call from a listed address, or ask MOOKHPay to change the list |
403 | 3025 | PLATFORM_GRANT_SCOPE_MISSING | Payouts and login links only: the account's grant lacks payouts:write or login_links:write | Ask the owner to link again with the scope |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | Unknown, another platform's, revoked or malformed id | Stop using the id |
409 | 3061 | PLATFORM_ACCOUNT_DISCONNECTED | Pocket mode only: the person disconnected your platform. It does not count against the unknown-id limit | Stop calling for the account until they link again |
429 | 1804 | RATE_LIMIT_EXCEEDED | Too many requests, or too many unknown ids in an hour | Wait Retry-After seconds |
503 | 2782 | AUTHN_UNAVAILABLE | The key could not be checked | Retry with backoff |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | Accounts could not be read right now | Retry with backoff |
The full list is in Errors.
The platform pages
- Quickstart: open an account, take a payment with a fee, read the balance and pay out.
- Open seller accounts
- Take payments with a fee
- Balances and dashboards
- Pay into your users' pockets: pay-ins, pocket payouts and payout numbers
- Pay out sellers, including request signing
- Login links and the view-only visit
- Link an existing account
- Business accounts for sellers
- What sellers see and control
- Building a creator marketplace, the whole flow in one app
- Build a creator payouts platform, the same with pockets