Authentication

API authentication using secret keys

6 min read

Authentication

Flonk KYC uses secret keys to authenticate server-side API requests. Manage your API keys in the Flonk Dashboard.

API Keys

A new account starts with test keys only. Live keys are created later, when you are ready to run real verifications.

KeyWhereUse
Publishable pk_test_* / pk_live_* / pk_sandbox_*BrowserLoads project branding; safe to expose.
Secret sk_test_* / sk_live_* / sk_sandbox_*Server onlyCreates sessions, authenticates the API.
Webhook secret whsec_*Server onlyVerifies that a webhook really comes from Flonk.
  • Test keys (pk_test_*, sk_test_*, and the test whsec_*) are in Dashboard → Settings → Test Mode. They exist from the moment you sign up.
  • Live keys (pk_live_*, sk_live_*) are in Dashboard → Settings → API, with Production selected.
  • Sandbox keys (pk_sandbox_*, sk_sandbox_*) are in the same place, with Sandbox selected. Unlike test keys, they create real verifications: documents are processed and each completed session is charged (or uses a free verification). Sandbox sessions do not wait for project approval; Live ones do.

Never expose a secret key (sk_*) in client-side code.

Download your keys

The last step of sign-up shows your test keys and the webhook signing secret, and offers Download keys (.env). The file uses the variable names below:

bash
FLONK_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxx
FLONK_SECRET_KEY=sk_test_xxxxxxxxxxxx
FLONK_WEBHOOK_SECRET=whsec_test_xxxxxxxxxxxx

Keep the file private and do not commit it. You can read the same keys again at any time in Settings → Test Mode.

Test mode

Any request made with an sk_test_* key runs in test mode:

  • No documents are processed. The result comes from a ready-made test person, picked by the clientMetadata.email you send. See Direct API → Test mode for the list.
  • Not charged by default, so no free verification is used.
  • Webhooks are real. They go to the webhook URL set in Settings → Test Mode, are signed with the test whsec_* secret, and carry livemode: false.
  • Your live data is not involved. Test sessions always run in the project's sandbox environment, never in the live one.

Test mode does not check real documents, so a pass in test mode says nothing about how a real passport or ID will be read. Run a few real verifications with a live key before you launch.

Go live

Create a Live key in Settings → API (with Production selected) when your test sessions and test webhooks work. The secret is shown once; copy it into your server's environment and replace sk_test_* with sk_live_* (and pk_test_* with pk_live_* in the browser).

New accounts get 300 free verifications with no end date. Each completed verification uses one; test sessions made with your test keys are not charged by default. When they run out, top up in Dashboard → Billing.

The first real verification with a live key is the last step of the dashboard setup guide (see below).

Setup guide in the dashboard

The dashboard walks you through the same path in 5 steps:

  1. Your test keys are ready.
  2. Create a test session.
  3. Receive a test webhook.
  4. Create a Live key.
  5. Run your first real verification.

The guide opens once as a window on your first visit, and afterwards stays as a short strip on Overview. Steps are ticked automatically when Flonk sees the result, for example when your server accepts a test webhook, so you do not have to mark anything yourself.

Secret Key Authentication

typescript
import { FlonkKYCServer } from '@flonkid/kyc/server';
const flonk = new FlonkKYCServer({
secretKey: process.env.FLONK_SECRET_KEY!,
});
// SDK handles Authorization header automatically
const session = await flonk.createSession({
clientMetadata: { email: 'user@example.com' },
});

Manual (fetch)

typescript
const response = await fetch('https://api.flonk.id/v1/sessions', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_test_your_secret_key', // sk_live_... in production
'Content-Type': 'application/json'
},
body: JSON.stringify({
clientMetadata: { email: 'user@example.com' }
})
});

API Versioning

The REST API is versioned by date, pinned with an optional Flonk-Version request header (the SDK sends the version it was built against automatically):

Flonk-Version: 2026-06-01

The API is additive-only within a version — new optional fields and endpoints never change behaviour for existing callers. A genuinely breaking change would ship under a new date, and requests pinned to the older date keep getting the old response shape. Omitting the header resolves to the current version. The server echoes the resolved version in the Flonk-Version response header.

Install SDK

bash
npm install @flonkid/kyc
# or
yarn add @flonkid/kyc
ImportUse
@flonkid/kycBrowser — widget iframe + postMessage
@flonkid/kyc/serverNode.js — sessions API + webhook verification

Environment Variables

Configure your keys in environment variables:

bash
# Server-side (never expose to frontend)
FLONK_SECRET_KEY=sk_test_xxxxxxxxxxxx # sk_live_... in production
FLONK_API_URL=https://api.flonk.id/v1
FLONK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx

Viewing and rotating keys

Sandbox and live secret keys are shown once, when you create them in Settings → API (Create secret key for the first one, Rotate key afterwards). Copy the key straight into your secret store, or use Download .txt in the same window to keep a copy; the dashboard only shows its last four characters afterwards, and Flonk stores only a hash of the key, so it cannot show it again. If you lose it, rotate: the new key works immediately and the previous one keeps working for 7 days, so you can update your servers without downtime. The window shows the exact date the old key stops working.

Rotating a key and showing a webhook secret ask you to confirm it is you, with the code from your authenticator app or, if two-factor authentication is off, a code sent to your email. Test-mode keys (pk_test_*, sk_test_*) stay visible in Settings → Test Mode; regenerating them there replaces them.

Security Best Practices

  • Never expose secret keys in frontend code, git repositories, or logs
  • Use environment variables to store keys
  • Rotate keys regularly if you suspect a leak
  • Use test keys (sk_test_*) for development and automated tests

Rate Limits

EndpointRate Limit
Create Session100 req/min
Get Session500 req/min
WebhooksUnlimited

If you exceed rate limits, you'll receive a 429 Too Many Requests response.