The basics
API keys, scopes and modes
Get keys for test and live, give each only the scopes it needs, roll them without downtime and restrict where they work.
Every call carries an API key in Authorization: Bearer …. The key decides three things: whose account the call acts on, in which mode (test or live), and what it may do (its scopes). Test and live are separate worlds: a test key never touches live money or live credentials.
There are two kinds of keys you issue yourself:
- Secret keys (
sk) carry every merchant scope. Keep them on your servers only. - Restricted keys (
rk) carry only the scopes you list. Use them for every integration that does one job: a bank's deposit system, a reporting job, a partner you give a key to.
A secret key ignores any scope list you send; only a restricted key uses it. When you hand a key to someone else, always issue an rk.
Before you start
A key with keys:manage to issue and manage keys (your first keys come from onboarding or the partner portal). Secrets are shown once, when the key is issued or rolled: store them in a secret manager straight away.
The flow at a glance
| # | Who | What happens |
|---|---|---|
| 1 | Your team | Issues a restricted key with only the scopes the job needs, in the right mode. |
| 2 | Your team | Optionally restricts it to your server addresses and to amount ceilings. |
| 3 | Your system | Calls the API with the key. |
| 4 | Your team | Rolls the key before it expires, deploys the new one, and lets the old one lapse. |
1. Issue a restricted key
Your team.
POST /v1/api-keys · API reference
type: "rk" with the scopes the job needs. The key's mode is the mode of the key you call with. The answer holds the secret once; it is never shown again.
Common sets: a bank's cash deposits need transactions:read, transactions:write, reconciliation:read, reconciliation:write and events:read; a merchant's server needs payments:read, payments:write and refunds:write; a reporting job needs only the :read scopes.
Request
{
"name": "Deposit system",
"type": "rk",
"scopes": [
"transactions:read",
"transactions:write",
"reconciliation:read",
"reconciliation:write",
"events:read"
]
}
Response
{
"id": "3L3THifwTFCkhbAHXc5ffaCyZaa",
"mode": "live",
"name": "Deposit system",
"type": "rk",
"scopes": [
"events:read",
"reconciliation:read",
"reconciliation:write",
"transactions:read",
"transactions:write"
],
"last4": "XSzA",
"secret": "kp_live_rk_…",
"status": "active",
"use_count": 0,
"created_at": "2026-10-22T15:07:45Z",
"expires_at": "2027-10-22T15:07:45Z"
}
Live keys expire after 12 months unless set otherwise, with reminders 30, 7 and 1 days before. The prefix (kp_live_rk_, kp_test_sk_…) tells you the mode and kind at a glance.
2. Restrict where and how much
Your team, optionally.
PATCH /v1/api-keys/{id} · API reference
Limit the key to your servers' addresses (allowed_ips, single addresses or ranges) and to amount ceilings per transaction and per day. A call from another address is 403 ip_not_allowed; a transaction above a ceiling is 422 limit_exceeded naming the rule. The change holds from the next request.
Request
{
"allowed_ips": [
"41.220.160.10",
"196.28.240.0/24"
],
"max_amount": "50000.00",
"daily_amount": "500000.00",
"currency": "MZN"
}
3. Roll a key without downtime
Your team, before the key expires or whenever it may have leaked.
POST /v1/api-keys/{id}/roll · API reference
Issues a new key with the same kind and scopes, and gives the old one a grace period (default 24 hours, at most 7 days). Both work meanwhile: deploy the new secret, check its use_count rises, and let the old one expire. A key can be rolled once.
Request
{
"grace": "24h"
}
4. Watch how a key is used
Your team.
GET /v1/api-keys/{id}/usage · API reference
Last use and address, where it was used from, and requests and errors per day. A key used from a new country or network, or with a sudden spike, raises an alert event.
5. Revoke a key
Your team, at once when it leaked or is no longer needed.
DELETE /v1/api-keys/{id} · API reference
The key stops working immediately, even during a roll's grace period.
States
| State | What it means |
|---|---|
active | Works. |
expiring | Works until |
expired | Past its expiry. Calls are refused. |
revoked | Revoked. Calls are refused. |
Events
| Event | What it tells you |
|---|---|
credential.api_key.created | A key was issued. |
credential.api_key.rotated | A key was rolled. |
credential.api_key.expiring | A key expires soon. |
credential.api_key.revoked | A key was revoked. |
credential.used_from_new_location | A key was used from a country or network it never used before. |
Errors that matter here
Every error is application/problem+json with a stable code; branch on the code, not the message. The full list is in the error catalogue.
| Error | When | What to do |
|---|---|---|
401 unauthorized | No key, an unknown key, or an expired or revoked one. | Check the |
403 insufficient_scope | The key lacks the scope the call needs; the problem names it. | Issue a restricted key that lists it. |
403 ip_not_allowed | The call came from an address the key is not allowed from. | Add the address, or call from an allowed server. |
409 idempotency_replay_unavailable | A key-issuing call was repeated with the same | List your keys to find the one it made, and roll it if the secret was lost. |
Testing it
Issue a test-mode rk with one scope and call an endpoint it does not cover: you get 403 insufficient_scope naming the scope. Restrict it to an address you are not calling from to see ip_not_allowed.