Skip to content

Open seller accounts ​

POST /accounts opens a full MOOKHPay account, with a wallet, for one of your sellers. The seller does nothing first and needs no app. They own the account from the start, and can claim it later with their phone.

The key needs accounts:write. Reading accounts needs accounts:read.

Before you call ​

  • Show the seller MOOKHPay's terms and record when they accepted them and which version. You send both, and MOOKHPay keeps them with the account as your attestation, along with the IP address your request came from.
  • Check the phone number is the seller's own. MOOKHPay texts it, and it is the number the seller will claim the account with. It must be in your key's country: +254 on the Kenyan host, +256 on the Ugandan one.
  • Pick an external_reference: your own id for this seller, unique among your platform's accounts.

Create the account ​

FieldTypeRequiredConstraints
phonestringYesE.164 with +: +254 or +256 and 9 digits, in your key's country
first_namestringYes1 to 100 characters, not only spaces
last_namestringYes1 to 100 characters, not only spaces
emailstringNoUp to 254 characters, an address shape
usernamestringNo3 to 50 characters: a-z, 0-9, _. Without one, MOOKHPay makes one from the name and four digits, such as joyotieno4821
external_referencestringYes1 to 100 printable ASCII characters, no spaces. Unique among your accounts
terms.accepted_atstringYesISO 8601 with a time zone. Not more than 5 minutes in the future
terms.versionstringYes1 to 40 characters: letters, digits, ., _, -

Unknown fields are refused with 400 and code 1701, including platform_id, user_id, status, scopes and kyc_status. Send an Idempotency-Key on every create.

sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY" \
  -H "Idempotency-Key: seller-8841" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+254712345678",
    "first_name": "Joy",
    "last_name": "Otieno",
    "email": "joy@example.com",
    "external_reference": "seller-8841",
    "terms": { "accepted_at": "2026-11-20T09:12:00Z", "version": "2026-10" }
  }'
js
const res = await fetch(
  "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}`,
      "Idempotency-Key": "seller-8841",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      phone: "+254712345678",
      first_name: "Joy",
      last_name: "Otieno",
      email: "joy@example.com",
      external_reference: "seller-8841",
      terms: { accepted_at: "2026-11-20T09:12:00Z", version: "2026-10" },
    }),
  },
);
const body = await res.json();
if (!body.ok) throw new Error(`${res.status} ${body.code}: ${body.description}`);
console.log(body.data.id); // acct_ke_…
python
import os
import requests

res = requests.post(
    "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts",
    headers={
        "Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}",
        "Idempotency-Key": "seller-8841",
    },
    json={
        "phone": "+254712345678",
        "first_name": "Joy",
        "last_name": "Otieno",
        "email": "joy@example.com",
        "external_reference": "seller-8841",
        "terms": {"accepted_at": "2026-11-20T09:12:00Z", "version": "2026-10"},
    },
    timeout=30,
)
body = res.json()
if not body["ok"]:
    raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
print(body["data"]["id"])  # acct_ke_…
php
<?php
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY"),
        "Idempotency-Key: seller-8841",
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "phone" => "+254712345678",
        "first_name" => "Joy",
        "last_name" => "Otieno",
        "email" => "joy@example.com",
        "external_reference" => "seller-8841",
        "terms" => ["accepted_at" => "2026-11-20T09:12:00Z", "version" => "2026-10"],
    ]),
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if (!$body["ok"]) {
    throw new RuntimeException("$status {$body['code']}: {$body['description']}");
}
echo $body["data"]["id"], "\n"; // acct_ke_…

A new account answers 201:

json
{
  "ok": true,
  "description": "Account created",
  "data": {
    "id": "acct_ke_9c2f41b07e5d38a6c1f0b294",
    "username": "joyotieno4821",
    "status": "active",
    "origin": "created",
    "external_reference": "seller-8841",
    "requirements": { "currently_due": ["identity"], "pending": [] },
    "capabilities": { "payments": true, "payouts": true },
    "created_at": "2026-11-20T09:12:04.000Z"
  }
}

Store data.id against your seller. It is your platform's id for the account, and every account route takes it. It is not the seller's username, and another platform that reaches the same person has a different id. The fields are described in The account object.

You also receive account.created on your webhook endpoints, once, for a new account. A replay sends nothing.

The wallet takes a moment ​

MOOKHPay's ledger sets up the seller's wallet just after the account is made. A checkout or charge for the seller made before the wallet exists answers 409 with code 2709 (WALLET_NOT_PROVISIONED). Retry after a second or two. A balance read in that moment answers 200 with no wallets and a total of 0, and a transactions read answers 404 with code 3019.

What the seller receives ​

MOOKHPay texts the seller's phone. The text names your organisation and the seller's username:

text
Kilimani Market opened a MOOKHPay account for you (@joyotieno4821). To sign in, open MOOKHPay and use Forgot PIN to set your PIN.

The text is sent once. If it cannot be sent, the account is still created; nothing tells you.

The seller claims the account ​

A new account has no PIN and an unconfirmed phone. Until the seller claims it, nobody can sign in to it with a PIN or send money from it. Your platform can still take payments for it and pay it out to the seller's own phone.

The seller claims it in one of two ways:

  • Forgot PIN. They open MOOKHPay, choose Forgot PIN, enter the phone number you used, type the code MOOKHPay texts them and choose a PIN.
  • From a login link. A seller who opens a login link can claim the account inside that visit: a code texted to their phone, then a new PIN. The view-only visit ends and a full session starts. This path exists only where login links are switched on; Forgot PIN works everywhere.

Either way the phone is confirmed and the account becomes an ordinary MOOKHPay account the seller signs in to. You receive account.claimed, with data.claimed_at, within about a minute.

When the phone already has an account ​

If the phone number already has a MOOKHPay account, the call answers 409 with code 2944 and creates nothing. You get no access to that account and no hint about it beyond the code. Link the account instead: the owner approves your access with their PIN.

Retries and duplicates ​

Two things stop a seller getting two accounts.

The Idempotency-Key. The same key with the same body answers the same account with 200 and "description": "Account already created". The same key with a different body answers 422 with code 3015. A key whose create was refused, for example with 2944, is released and can be used again for a corrected request.

The external_reference. A create with an external_reference you already used, and the same phone, first name and last name, answers the existing account with 200, whatever the Idempotency-Key. With a different phone or name it answers 409 with code 2945.

Use your own seller id as both, and a retry after a timeout is always safe.

Other refusals ​

HTTPCodeNameWhenWhat to do
4001701INVALID_REQUEST_DATAA field breaks its rule, an unknown field was sent, the phone is not in this country, or terms.accepted_at is in the futureFix the field
4092944PLATFORM_ACCOUNT_EXISTSThe phone already has a MOOKHPay accountLink it
4092945PLATFORM_REFERENCE_TAKENThe external_reference names another sellerUse a different reference, or fix the phone or name
4093011PLATFORM_USERNAME_TAKENThe username you chose is takenChoose another, or leave it out
4223015IDEMPOTENCY_KEY_REUSEDSame key, different bodyUse a new key for a different request
4292950PLATFORM_DAILY_ACCOUNTS_REACHEDYour platform has opened as many accounts today as MOOKHPay allows, counted from midnight East Africa TimeWait until tomorrow, or ask MOOKHPay to raise the cap
5033016PLATFORM_ACCOUNTS_UNAVAILABLEAccounts could not be created right nowRetry with the same key

POST /accounts checks your key on every call, with no cache, so a revoked key stops working here at once.

Requirements and capabilities ​

FieldToday
requirements.currently_due["identity"] until the seller passes MOOKHPay's identity check in the app, then []
requirements.pendingAlways []
capabilities.paymentsAlways true
capabilities.payoutsAlways true

capabilities is fixed at true for every account. It does not mean the account has passed any check, and it does not change when identity is due. An account you opened works while identity is due: it takes payments and can be paid out, under a daily cap on money out for platform accounts whose identity has not been checked, where MOOKHPay switches that cap on (the amount is set per deployment; there is no default). Over it, a payout answers 422 with code 2948. A linked account follows its owner's own verification.

There is no API for submitting a seller's identity. The seller does it in MOOKHPay.

Read and list accounts ​

RouteReturns
GET /accounts/{id}One account
GET /accountsYour accounts, created and linked, newest first, 1 to 100 a page (default 20)

GET /accounts returns next_cursor, an opaque string tied to your platform. Pass it back as cursor for the next page; it is null on the last page. An edited cursor, or one from another platform, answers 400 with code 3012. See Pagination.

sh
curl "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts?limit=100" \
  -H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"
js
async function* allAccounts() {
  let cursor = null;
  do {
    const url = new URL("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts");
    url.searchParams.set("limit", "100");
    if (cursor) url.searchParams.set("cursor", cursor);
    const res = await fetch(url, {
      headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
    });
    const body = await res.json();
    if (!body.ok) throw new Error(`${res.status} ${body.code}: ${body.description}`);
    yield* body.data.accounts;
    cursor = body.data.next_cursor;
  } while (cursor);
}

for await (const account of allAccounts()) console.log(account.id, account.origin);
python
import os
import requests

def all_accounts():
    cursor = None
    while True:
        params = {"limit": 100}
        if cursor:
            params["cursor"] = cursor
        res = requests.get(
            "https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts",
            headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
            params=params,
            timeout=30,
        )
        body = res.json()
        if not body["ok"]:
            raise RuntimeError(f"{res.status_code} {body['code']}: {body['description']}")
        yield from body["data"]["accounts"]
        cursor = body["data"]["next_cursor"]
        if not cursor:
            return

for account in all_accounts():
    print(account["id"], account["origin"])
php
<?php
function allAccounts(): Generator {
    $cursor = null;
    do {
        $query = http_build_query(array_filter(["limit" => 100, "cursor" => $cursor]));
        $ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts?$query");
        curl_setopt_array($ch, [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
        ]);
        $body = json_decode(curl_exec($ch), true);
        if (!$body["ok"]) {
            throw new RuntimeException("{$body['code']}: {$body['description']}");
        }
        yield from $body["data"]["accounts"];
        $cursor = $body["data"]["next_cursor"];
    } while ($cursor !== null);
}

foreach (allAccounts() as $account) {
    echo $account["id"], " ", $account["origin"], "\n";
}

An account whose owner revoked your access drops out of the list, and reading it by id answers 404 with code 2943.

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