Appearance
Retrieve an account link
Reads whether the person has approved a link request. Once they have, account holds the account id your platform now reaches.
You do not need this route to learn of an approval: MOOKHPay sends account.linked when the person approves, read by its account events job about once a minute. A read that finds the request approved queues the same event at once, and the event is never sent twice to one endpoint.
Endpoint
GET /v1/payments/merchant/account-links/{id}| Auth | Secret key |
| Scope | accounts:link |
| Platform | Your organisation must be switched on as a platform, and the call must come from an allowed address if MOOKHPay set a list |
| Switched on | Per deployment (PLATFORM_ACCOUNT_LINKS_ENABLED). Where it is off, the route answers 404 |
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_… |
Parameters
Path
| Name | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | The id Create an account link returned: plr_, the country, _ and 24 hex characters |
Example request
The samples poll every three seconds and stop at approved or expired.
sh
curl https://payments-ke-staging.mookhpay.co/v1/payments/merchant/account-links/plr_ke_5e0c7a2b9d41f3e8a6c1b047 \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
export async function waitForLink(linkId) {
for (;;) {
const res = await fetch(`${BASE}/account-links/${linkId}`, {
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
});
const answer = await res.json();
if (!answer.ok) throw new Error(`${res.status} ${answer.code}: ${answer.description}`);
const { status, account } = answer.data;
if (status === "approved") return account;
if (status === "expired") return null;
await new Promise((resolve) => setTimeout(resolve, 3000));
}
}
console.log(await waitForLink("plr_ke_5e0c7a2b9d41f3e8a6c1b047"));python
import os
import time
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def wait_for_link(link_id):
while True:
res = requests.get(
f"{BASE}/account-links/{link_id}",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=30,
)
answer = res.json()
if not answer["ok"]:
raise RuntimeError(f"{res.status_code} {answer['code']}: {answer['description']}")
if answer["data"]["status"] == "approved":
return answer["data"]["account"]
if answer["data"]["status"] == "expired":
return None
time.sleep(3)
print(wait_for_link("plr_ke_5e0c7a2b9d41f3e8a6c1b047"))php
<?php
function wait_for_link(string $linkId): ?string
{
while (true) {
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/account-links/{$linkId}");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('MOOKHPAY_SECRET_KEY')],
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (!$answer['ok']) {
throw new RuntimeException("{$status} {$answer['code']}: {$answer['description']}");
}
if ($answer['data']['status'] === 'approved') {
return $answer['data']['account'];
}
if ($answer['data']['status'] === 'expired') {
return null;
}
sleep(3);
}
}
var_dump(wait_for_link('plr_ke_5e0c7a2b9d41f3e8a6c1b047'));Response
200 OK with description Account link.
json
{
"ok": true,
"description": "Account link",
"data": {
"id": "plr_ke_5e0c7a2b9d41f3e8a6c1b047",
"status": "approved",
"account": "acct_ke_2d8f6b0c4a9e17d3b5f2a681",
"expires_at": "2026-11-20T09:30:00.000Z"
}
}Response fields
| Field | Type | Meaning |
|---|---|---|
id | string | The link request |
status | string | pending, approved or expired. See below |
account | string or null | The account id once approved, else null. Store it; every account route takes it |
expires_at | string | ISO 8601, UTC. When the request stops being approvable |
There is no url in this answer; it is returned only by the create call.
status | Meaning |
|---|---|
pending | Not approved yet, and not past expires_at. A phone with no MOOKHPay account stays pending until it expires |
approved | The person approved it with their PIN. Final |
expired | Past expires_at without approval. Final. Make a new link to ask again |
The person cannot decline in a way you can see: a request they ignore or turn down stays pending and then reads expired. Once approved, the account's grant holds the scopes you asked for; the person approves the request whole or not at all. Neither this answer nor the account object lists them. A call the grant does not cover answers 403 and code 3025.
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 3014 | IDENTITY_HEADER_REFUSED | The request carries a session or 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 accounts:link | Issue a key with the scope |
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 | Your organisation is not a platform, or its platform is suspended | Talk to MOOKHPay |
403 | 3013 | PLATFORM_IP_NOT_ALLOWED | The call came from an address not on your platform's allow-list | Call from a listed address |
404 | 3027 | ACCOUNT_LINK_NOT_FOUND | The link is unknown or another platform's | Check the id |
429 | 1804 | RATE_LIMIT_EXCEEDED | Over the rate limit | Wait Retry-After seconds, and poll less often |
503 | 2782 | AUTHN_UNAVAILABLE | The key could not be checked | Retry |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | The link's state or the linked account could not be read | Retry |
Rate limit
120 requests a minute, shared by every account, balance, transaction, payout read, account link and business account request route your platform calls. Over it: 429, code 1804, with Retry-After and data.retryAfter in seconds. Polling every few seconds for one person is well inside it; polling many links at once is not.