Appearance
Create a login link
Makes a one-time link that opens MOOKHPay signed in to one of your accounts, in a view-only session. Use it behind a "View on MOOKHPay" button. The session can read; it cannot send money or change settings. See Login links.
Redirect, never send
Make the link when the seller taps your button, and redirect their browser to it at once. Do not email it, text it, log it, store it or show it as text. Anyone who opens it within 60 seconds is signed in as the seller.
Endpoint
POST /v1/payments/merchant/accounts/{id}/login-links| Auth | Secret key |
| Scope | login_links:write on the key, and login_links:write in the account's grant |
| 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_LOGIN_LINKS_ENABLED). Where it is off, the route answers 404 |
The key is checked with authn on every call, with no 60-second cache.
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer mkp_… |
No Idempotency-Key: every call makes a new link, and a retry makes another one. No body: send nothing, or an empty JSON object {} with Content-Type: application/json.
Parameters
Path
| Name | Type | Required | Constraints |
|---|---|---|---|
id | string | Yes | One of your account ids: acct_, the country, _ and 24 hex characters. A person's account only |
Example request
Each sample redirects the browser itself. Never return the URL to a page as data you then display.
sh
curl -X POST https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/acct_ke_9c2f41b07e5d38a6c1f0b294/login-links \
-H "Authorization: Bearer $MOOKHPAY_SECRET_KEY"js
import { createServer } from "node:http";
const BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant";
async function loginLink(accountId) {
const res = await fetch(`${BASE}/accounts/${accountId}/login-links`, {
method: "POST",
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}`);
return answer.data.url;
}
createServer(async (req, res) => {
if (req.url !== "/view-on-mookhpay") return res.writeHead(404).end();
const accountId = "acct_ke_9c2f41b07e5d38a6c1f0b294";
const url = await loginLink(accountId);
res.writeHead(303, { Location: url, "Cache-Control": "no-store" }).end();
}).listen(3000);python
import os
import requests
BASE = "https://payments-ke-staging.mookhpay.co/v1/payments/merchant"
def login_link(account_id):
res = requests.post(
f"{BASE}/accounts/{account_id}/login-links",
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']}")
return answer["data"]["url"]
# In a Flask view:
# return redirect(login_link(seller.mookhpay_account_id), code=303)php
<?php
function login_link(string $accountId): string
{
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{$accountId}/login-links");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
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']}");
}
return $answer['data']['url'];
}
header('Cache-Control: no-store');
header('Location: ' . login_link('acct_ke_9c2f41b07e5d38a6c1f0b294'), true, 303);The PHP sample uses CURLOPT_CUSTOMREQUEST with no body. CURLOPT_POST with empty post fields sends Content-Type: application/x-www-form-urlencoded, which this route refuses.
Response
201 Created with description Login link and Cache-Control: no-store.
json
{
"ok": true,
"description": "Login link",
"data": {
"url": "https://mookhpay.co/connect/open?c=KE#t=mll_3sQe8Kp1vNw0ZbX4yR7tUa9cLm2dHf6gJk5iOq1sW8e",
"expires_at": "2026-11-20T09:01:00.000Z"
}
}Response fields
| Field | Type | Meaning |
|---|---|---|
url | string | The link: MOOKHPay's /connect/open page, the country in c, and the one-time token after #t=. The token is in the fragment, so the browser does not send it to a server when it loads the page. It works once |
expires_at | string | ISO 8601, UTC. 60 seconds after the link was made |
The session the link opens:
- lasts 30 minutes and is not extended by use;
- can read the seller's balances, transactions, payment links, payment requests and chats;
- cannot send money, change settings or make anything. For that the seller signs in with their PIN;
- lets a seller with no PIN yet claim the account: a code texted to their phone, then a new PIN. That ends the view-only session and starts a full one;
- does not sign the seller out anywhere else;
- ends at once if the seller disconnects your platform.
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | The request has a body (other than {}), or its body is not valid JSON | Send no body |
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 login_links:write | 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 |
403 | 3025 | PLATFORM_GRANT_SCOPE_MISSING | The account's grant does not include login_links:write | Ask the owner to approve a new account link with it |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | The account is unknown, another platform's, revoked or malformed; it is a business account; or its holder can no longer sign in (closed, banned, disabled or deleted) | Check the id. A business account has no login link |
415 | 1701 | INVALID_REQUEST_DATA | A body was sent with a content type other than JSON | Send no body |
429 | 1804 | RATE_LIMIT_EXCEEDED | Your platform reached its limit of unknown account ids | Wait Retry-After seconds |
429 | 3026 | LOGIN_LINK_LIMIT_REACHED | Too many links from your platform this minute (all its keys together, unknown accounts included), or from your platform for this account this hour | Wait. Make a link only when the seller taps the button |
503 | 2782 | AUTHN_UNAVAILABLE | The key could not be checked | Retry |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | The link could not be made | Retry |
Rate limit
| Bucket | Default | Answer |
|---|---|---|
| Links from your platform, all keys together, counted before the account is looked up | 30 a minute (PLATFORM_LOGIN_LINKS_PER_MINUTE) | 429, code 3026, with Retry-After and data.retryAfter |
| Links your platform makes for one account | 10 an hour, counted for your platform and that account only; other platforms' links for the same person do not count (PLATFORM_LOGIN_LINK_MINTS_PER_HOUR on authn) | 429, code 3026, no Retry-After |