Skip to content
Dashboard

Warning: Provisional contract proposal

These endpoints are not operational and no SDK is published. Examples use test identifiers only and nothing is sent anywhere.

Get started

API keys

The keys that identify your account: what each one is for, how to recognize it by its prefix, and how to store, roll and replace it safely.

Key types

Each account has one secret key and one publishable key per environment, plus a signing secret per webhook endpoint. Only the test environment exists today, so every key you can get starts with a test prefix.

  • Secret key: authenticates every API call from your server. Treat it like a password.
  • Publishable key: safe to embed in a page, but reserved for future client-side use. No documented endpoint accepts it yet (see Authentication).
  • Webhook signing secret: verifies that a webhook delivery came from KrokoPay. It is not an API key and cannot call the API (see Webhooks).

Key format and prefixes

The prefix tells you what a key is before you use it. Code scanners and reviewers can match it, and your own code can check it at startup.

PrefixKeyExample
kp_test_sk_Test secret key (prefix + 24 hex characters)kp_test_sk_4f9a2c7e1b8d4a6f9c3e5d7b
kp_test_pk_Test publishable key (prefix + 24 hex characters)kp_test_pk_8b1d3f5a7c9e2b4d6f8a0c2e
whsec_test_Test webhook signing secret (prefix + 20 hex characters)whsec_test_2e4c6a8b0d1f3a5c7e9b
To be announcedLive keysNot available yet
Information: The examples in this documentation are fictional test values. They are fine to copy into a tutorial; real keys from your dashboard are not.

Where to find your keys

Open Developers → API keys in the dashboard. The secret key is masked until you reveal it; copy it straight into your environment instead of pasting it into chats or tickets. Signing secrets are shown on each endpoint under Developers → Webhooks.

Storing keys

Keep the secret key in an environment variable or in your platform's secret manager, and read it only in server code. Exclude local env files from version control.

# Server-side only. Never commit this file.KROKOPAY_SECRET_KEY=kp_test_sk_4f9a2c7e1b8d4a6f9c3e5d7b

Check the key once at startup so a missing or wrong key fails loudly in your logs, not as a 401 in front of a buyer:

Fail fast on a wrong keyTypeScript
// server/krokopay.ts: read the key once, on the server, and fail fast.const key = process.env.KROKOPAY_SECRET_KEY;​if (!key) {  throw new Error("KROKOPAY_SECRET_KEY is not set");}if (!/^kp_test_sk_[0-9a-f]{24}$/.test(key)) {  throw new Error("KROKOPAY_SECRET_KEY must be a test secret key (kp_test_sk_…)");}​export async function krokopay(path: string, init: RequestInit = {}) {  return fetch(`https://api.krokopay.app/v1${path}`, {    ...init,    headers: { ...init.headers, Authorization: `Bearer ${key}` },  });}
  • Never put the secret key in front-end code, mobile apps, public repositories or URLs.
  • Give each service that calls the API access to the variable, not a copy of the value in its config.
  • Never paste the key into chats, tickets or screenshots. Share access to the secret manager instead.

Rolling keys

Rolling a key creates a new one and revokes the old one immediately. There is no overlap period, so any request still using the old key gets 401 invalid_api_key from that moment on.

  1. Step 1: Prepare the deploy

    Make sure you can update KROKOPAY_SECRET_KEY and restart your server in one go.

  2. Step 2: Roll the key

    In Developers → API keys, choose roll on the secret key and copy the new value.

  3. Step 3: Update and restart

    Set the new value in every environment that uses it and restart, then watch your logs for 401 responses.

Warning: Plan for a short gap

Because the old key stops working at once, calls made between the roll and your restart fail. Roll at a quiet moment, and retry those calls with the same Idempotency-Key once the new key is live.

If a key leaks

  1. Roll the secret key right away. Do not wait to find out how it leaked.
  2. Deploy the new key everywhere it is used.
  3. Review recent requests in Developers → Logs and your charges for anything you did not create.
  4. Remove the old value from wherever it was exposed, including commit history and shared documents.

Checklist

  • The secret key is read from an environment variable on the server only.
  • Env files are listed in .gitignore.
  • Your code checks the kp_test_sk_ prefix at startup.
  • You know how to roll the key and redeploy in one step.
  • Logs never contain the full key.