API authentication — PayBot docs
Skip to content
On this page
  1. The key
  2. Modes
  3. Scopes
  4. Creating a key
  5. Rotation
  6. OAuth

API authentication

Use an API key for the REST API and MCP. A cabinet session is for a person in a browser or the app, not for scripts.

The key#

Shape: pb_<mode>_<prefix>_<secret>. Mode is test or live. The 12-character prefix is visible in the cabinet and logs. The secret is shown once, at creation.

HowHeader
RecommendedAuthorization: Bearer <key>
REST alternativeX-API-Key: <key>
MCPAuthorization: Bearer <key> only
bash
curl -sS "https://paybot.kz/v1/payments?limit=1" -H "Authorization: Bearer $PAYBOT_API_KEY"

A key is bound to one business and one mode. X-Merchant-Id is not needed.

Modes#

ModeBehaviour
testSandbox. Payments are simulated, no Kaspi account is used, no money moves. Sees test data only.
liveReal payments to your Kaspi account.

Some setup needs a live key even to configure it (subscription plans, publishing templates): the error is live_key_required or live_only.

Scopes#

Scopes do not imply each other. Grant only what is needed.

ScopeAllows
readRead data.
writeCreate and change, except money.
publishAsk to publish something public. A person approves unless the key has auto_publish.
broadcastAsk to message customers. Always waits for a person.
moneyRefunds and anything that moves money. Needs allow_money: true at creation.

A missing scope returns 403 insufficient_scope.

Creating a key#

Cabinet only (POST /v1/api-keys with a session). An API key cannot create keys.

FieldDescription
modelive or test. Required.
scopes1 to 5 scopes. Required.
nameA label for the cabinet.
expires_in_daysLifetime, 1 to 3650. Omit for a key that never expires.
allowed_ipsUp to 32 addresses or CIDRs. Omit to allow any.
allow_moneytrue when scopes contain money.
grants.auto_publishLets the key publish without approval. Needs the publish scope.

Rotation#

POST /v1/api-keys/{id}/rotate (cabinet) issues a successor with the same mode, scopes and IP list. The old key keeps working for grace_hours (default 24, at most 168). The new key does not inherit the old expiry.

  1. Issue the new key.
  2. Deploy it.
  3. Verify a call with it.
  4. Let the old key lapse, or revoke it with DELETE /v1/api-keys/{id}.

Revoked, expired and unknown keys all return the same 401.

OAuth#

For connectors that cannot send a header (Claude.ai, ChatGPT web), see OAuth for MCP connectors (Russian).