Appearance
Login links
A login link opens MOOKHPay for a seller, already signed in to their own account, for a short view-only visit. Use it behind a "View on MOOKHPay" button in your app, so a seller can see their full history and payment links without signing in.
POST /accounts/{id}/login-links returns the link.
| You need | |
|---|---|
A key with login_links:write | |
The account's grant to include login_links:write | Every account you opened has it. A linked account has it only if the owner approved it. Otherwise 403 with code 3025 |
| A person's account | A business account has no login link: 404 with code 2943 |
PLATFORM_LOGIN_LINKS_ENABLED on the deployment | Otherwise the route answers 404 |
What a link is
- It works once, and for 60 seconds after it is made.
- Opening it starts a view-only session of 30 minutes in MOOKHPay. The session is not extended by use.
- The link looks like
https://mookhpay.co/connect/open?c=KE#t=mll_…: the MOOKHPay app's address on that deployment, the country, and a token. The token after#t=is the credential. It sits in the fragment, so browsers do not send it to servers or inRefererheaders. - Opening it does not sign the seller out of MOOKHPay on their other devices, and does not give your platform anything: you never see the session.
What the visit can do
The session a login link opens is limited. It can read, and almost nothing else.
| The seller can | The seller cannot, in this session |
|---|---|
| See their wallets, balances and movements, and money in and out summaries | Send money, withdraw or pay anything |
| See their payment links and their stats, bookings, plans, pledges, members and sign-ups | Create or change a payment link |
| See their payment requests, refunds, scheduled transfers and held payouts | Change any setting, including security settings |
| See their M-Chat conversations | Send a message |
| See their profile, sessions and verification status | Act for an organisation |
| Claim the account: a code texted to their phone, then a new PIN | Disconnect your platform or approve a link |
| Sign out | Use MOOKHPay's other routes |
To do anything else, the seller signs in with their PIN. A seller who has no PIN yet can claim the account from the visit; that ends the view-only session and starts a full one, and you receive account.claimed.
The session ends early if the seller disconnects your platform, or if your platform is suspended.
Build a "View on MOOKHPay" button
- Show a button or link in your app. Do not make the login link in advance.
- When the seller taps it, your server calls
POST /accounts/{id}/login-links. - Your server answers the tap with a redirect to
url, or your page navigates to it at once.
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
// An Express handler behind your own sign-in: GET /mookhpay/open
app.get("/mookhpay/open", async (req, res) => {
const account = req.user.mookhpayAccountId; // acct_ke_…, from your database
const answer = await fetch(
`https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/${account}/login-links`,
{
method: "POST",
headers: { Authorization: `Bearer ${process.env.MOOKHPAY_SECRET_KEY}` },
},
);
const body = await answer.json();
if (!body.ok) return res.status(502).send("MOOKHPay could not be opened. Try again.");
res.set("Cache-Control", "no-store");
res.redirect(303, body.data.url);
});python
# A Flask view behind your own sign-in: GET /mookhpay/open
import os
import requests
from flask import Flask, redirect, g
app = Flask(__name__)
@app.get("/mookhpay/open")
def open_mookhpay():
account = g.user.mookhpay_account_id # acct_ke_…, from your database
res = requests.post(
f"https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/{account}/login-links",
headers={"Authorization": f"Bearer {os.environ['MOOKHPAY_SECRET_KEY']}"},
timeout=10,
)
body = res.json()
if not body["ok"]:
return "MOOKHPay could not be opened. Try again.", 502
response = redirect(body["data"]["url"], code=303)
response.headers["Cache-Control"] = "no-store"
return responsephp
<?php
// mookhpay-open.php, behind your own sign-in
$account = $_SESSION["mookhpay_account_id"]; // acct_ke_…, from your database
$ch = curl_init("https://payments-ke-staging.mookhpay.co/v1/payments/merchant/accounts/$account/login-links");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("MOOKHPAY_SECRET_KEY")],
]);
$body = json_decode(curl_exec($ch), true);
if (!$body["ok"]) {
http_response_code(502);
exit("MOOKHPay could not be opened. Try again.");
}
header("Cache-Control: no-store");
header("Location: " . $body["data"]["url"], true, 303);The route takes no body and no Idempotency-Key. Every call makes a new link. A body that is not empty answers 400 with code 1701. The answer is 201 and carries Cache-Control: no-store:
json
{
"ok": true,
"description": "Login link",
"data": {
"url": "https://mookhpay.co/connect/open?c=KE#t=mll_Zx8…",
"expires_at": "2026-11-20T12:01:04.000Z"
}
}Keep the link secret
Anybody who opens the link in its 60 seconds is signed in as the seller, for 30 minutes of viewing.
- Do not email it, text it, put it in a push notification or show it as text.
- Do not store it in a database, a cache or a log. Most HTTP logging records redirect targets: turn that off for this route, or log only that a link was made.
- Make it only for the seller who is signed in to your app, for their own account.
- If a link is not used, let it expire. There is nothing to revoke.
Limits
| Limit | Default | Over it |
|---|---|---|
| Links per platform, across all its keys | 30 a minute, counting calls for unknown accounts too | 429 with code 3026, Retry-After and data.retryAfter |
| Links your platform makes for one account | 10 an hour, counted over the last hour. Links other platforms make for the same person do not count | 429 with code 3026, with no Retry-After |
MOOKHPay can set other numbers for a deployment. A seller who taps the button more than ten times in an hour waits.
Errors
| HTTP | Code | Name | When | What to do |
|---|---|---|---|---|
400 | 1701 | INVALID_REQUEST_DATA | A body was sent | Send no body |
403 | 2941 | API_KEY_SCOPE_REQUIRED | The key lacks login_links:write | Make a key with it |
403 | 3025 | PLATFORM_GRANT_SCOPE_MISSING | The account's owner did not grant it | Ask the owner to link again with it |
404 | 2943 | PLATFORM_ACCOUNT_NOT_FOUND | Unknown, another platform's, revoked, a business account, or a closed, banned or disabled account | Do not offer the button for this account |
429 | 3026 | LOGIN_LINK_LIMIT_REACHED | Over the per-key or per-account limit | Wait: Retry-After on the per-key limit, up to an hour on the per-account one |
503 | 3016 | PLATFORM_ACCOUNTS_UNAVAILABLE | The link could not be made right now | Ask the seller to tap again |