Webhooks

Setup and handle webhook notifications from Flonk KYC

18 min read

Webhooks allow your server to receive real-time notifications about KYC verification status changes.

What are Webhooks?

Webhooks are HTTP POST requests that Flonk sends to your server when verification events occur:

  • verification.completed — Automated verification finished (AI/system decision). This same event also fires when a reviewer approves a session that was in manual review. When Proof of Address is enabled in the project settings with Wait for PoA result in real time turned on, this event already contains the final poaStatus. With the toggle off, verification.completed fires after the identity step and a follow-up verification.updated arrives later with the PoA outcome — see Proof of Address for the full flow.
  • verification.status_changed — A status change made by an admin from the dashboard or as the outcome of manual review: the reviewer decision (approved / rejected; a rejection carries rejection_reason and reviewed_by), an automatic rejection taken by the checks themselves (rejected with a machine-readable rejection_reason and no reviewed_by), and — informational only — the moment a session enters manual_review or action_required (the latter carries the additive next_action field). The informational entry events let your KYC page show a "verification pending" state without polling.
  • verification.updated — Verification data was manually edited by admin (document fields, uploaded files), or the asynchronous PoA review finished (delivers poaStatus and poaConfidenceScore).

Review entry is now announced. When automated checks route a session to manual_review or action_required, an informational verification.status_changed fires with that newStatus (no decision yet). The final outcome still arrives later: approval fires verification.completed; rejection fires verification.status_changed with status: "rejected". These entry events are additive — integrators that only handle the reviewer decision can ignore them.

Setup

1. Create endpoint in your application

1import { FlonkKYCServer } from '@flonkid/kyc/server';
2
3const flonk = new FlonkKYCServer({
4 secretKey: process.env.FLONK_SECRET_KEY!,
5});
6
7// Express webhook handler (use raw body for signature verification)
8app.post('/webhooks/kyc',
9 express.raw({ type: 'application/json' }),
10 (req, res) => {
11 const signature = req.headers['x-signature-256'] as string;
12
13 try {
14 // Automatically detects signature format (sha256= or t=...,v1=...)
15 const event = flonk.webhooks.constructEvent(
16 req.body.toString(),
17 signature,
18 process.env.FLONK_WEBHOOK_SECRET!,
19 );
20
21 // Process the verified event
22 const verification = event.data.object;
23 console.log(`Verification ${verification.id}: ${verification.status}`);
24 console.log('Extracted data:', verification.extracted_data);
25
26 res.sendStatus(200);
27 } catch (err) {
28 console.error('Webhook verification failed:', err instanceof Error ? err.message : err);
29 res.sendStatus(400);
30 }
31 }
32);

2. Configure URL in Flonk Dashboard

  1. Go to Flonk Dashboard
  2. Select Settings → API and pick the environment (Sandbox or Production)
  3. Under Webhooks, enter your endpoint URL (for example https://yourdomain.com/api/kyc/webhook) and save it with the check button
  4. On the Webhook Secret row press Show. You may be asked to confirm it's you first. Copy the whsec_… value

Each environment has its own endpoint URL and its own webhook secret. For test mode the URL and secret are set separately, in Settings → Test Mode.

The Settings → Webhooks tab does not hold the URL. It is the delivery history: every delivery, its attempts, and the failures you can retry (see Delivery status and failed deliveries).

Webhook Payload Format

All webhook payloads follow this structure:

json
{
"id": "evt_1234567890",
"type": "verification.completed",
"created": 1640995200,
"livemode": true,
"data": {
"object": {
"id": "verification_attempt_id",
"client_id": "user_1761052168279",
"client_metadata": {},
"status": "completed",
"confidence": 0.9442,
"document_type": "id_card",
"extracted_data": {
"full_name": "JOHN DOE",
"first_name": "JOHN",
"last_name": "DOE",
"date_of_birth": "1990-01-15",
"nationality": "UKR",
"sex": "M"
},
"duplicate_verification": {
"is_duplicate": true,
"previous_verification_id": "cmohkbzfq000686fezoudgcuc",
"previous_verified_at": "2026-04-27T19:01:03.000Z",
"match_type": "document_number",
"similarity_score": 1
},
"created_at": "2025-10-21T13:10:10.584Z",
"test_mode": false
}
}
}

livemode tells you which kind of event you got. It is true for real sessions and false for test mode sessions (those made with a sk_test_* key) and for the dashboard's test ping. Test-mode events also carry test_mode: true inside data.object.

The signature is sent in the headers (not in the body). Flonk sends two, both HMAC-SHA256 with your webhook secret:

X-Signature: t=1700000000, v1=abc123... ← also replay-protected (signed timestamp)
X-Signature-256: sha256=def456... ← HMAC of the body
X-Event-Type: verification.completed
X-Event-Id: evt_1234567890

Both are fully valid signatures — both prove the request came from Flonk and the body wasn't tampered with. The only difference: X-Signature also signs a timestamp, so a captured request is rejected outside the skew window (default 5 min) — i.e. replay protection. X-Signature-256 has no timestamp, so a captured request stays valid; close that gap by deduping on event.id (recommended anyway). Prefer X-Signature when you want replay protection at the signature layer; X-Signature-256 is perfectly safe for authenticity + integrity.

Which secret signs what

EventSigned withWhere to find it
Real session (livemode: true)The webhook secret (whsec_…) of the environment that created the sessionSettings → API, Webhook Secret row (Sandbox and Production have one each)
Test mode (livemode: false)The project's test webhook secret (whsec_test_…)Settings → Test Mode, Test Webhook Secret

If your endpoint serves several environments, pick the secret by livemode (and by the environment you configured the URL for). A signature made with the wrong secret will never match.

The dashboard shows the live and sandbox secrets but has no rotate button for them. The test secret is replaced by Regenerate Keys in Settings → Test Mode, which also replaces the test publishable and secret keys, so update all three in your app.

Event Types

verification.completed

Sent when automated verification finishes (AI/system decision). Status is always completed.

Duplicate verification signal

When a verification completes successfully, Flonk checks whether the same document or person was already verified in the same project. If a match is found, the verification.completed webhook includes an optional duplicate_verification object.

This is a signal for your own risk logic. Flonk still completes the verification normally; your application decides whether to allow the user, block the user, send the case to manual review, or apply a custom threshold.

Duplicate checks are scoped to a project. The same person or document can be verified in a different project without being marked as a duplicate for your project.

Example:

json
{
"duplicate_verification": {
"is_duplicate": true,
"previous_verification_id": "cmohkbzfq000686fezoudgcuc",
"previous_verified_at": "2026-04-27T19:01:03.000Z",
"match_type": "document_number",
"similarity_score": 1
}
}

AML screening result

When AML screening is enabled and ran for the verification, verification.completed includes an optional aml object. It is absent when screening did not run. Only verification.completed carries it: the verification.status_changed event sent when a verification enters manual_review does not, so read the final result from verification.completed or from GET /v1/verifications/{sessionId}. The field is additive; no API version change.

json
{
"aml": {
"status": "clear",
"provider": "dilisense",
"checked_at": "2026-10-05T12:04:30.000Z",
"total_hits": 0,
"matched_hits": 0,
"cleared_hits": 0,
"confirmed_hits": 0,
"categories": []
}
}

status is clear, hit, or error. matched_hits counts the matches found, cleared_hits those a reviewer marked as false positives, and confirmed_hits those a reviewer confirmed. categories contains any of SANCTION, PEP, CRIMINAL, OTHER, ADVERSE_MEDIA. adverse_media_articles is added when adverse media screening is on; adverse media is informational and does not by itself hold a verification. Hit details are visible only in the dashboard.

Fields:

FieldTypeDescription
is_duplicatebooleanAlways true when the object is present
previous_verification_idstringID of the earlier successful verification in the same project
previous_verified_atstringISO 8601 timestamp of the earlier verification
match_type"document_number" | "personal_data"How the duplicate was detected
similarity_scorenumberMatch confidence from 0.0 to 1.0

match_type values:

ValueMeaningTypical score
document_numberExact blind-index match on the document number. This usually means the same physical document was used before.1.0
personal_dataBlind-index match on last name + date of birth. This can catch the same person using another document type, for example passport first and ID card later.0.95

When no duplicate is detected, duplicate_verification is omitted from the webhook payload.

Workflow and checks

When the session ran with a workflow, verification.completed also says which workflow version it ran and how each check ended. Both fields are additive and only on verification.completed; verification.status_changed, verification.updated and verification.aml_alert do not carry them.

json
{
"workflow": {
"id": "wf_clx1234567890",
"version_id": "clx0987654321",
"version": 3
},
"checks": [
{ "node_id": "node_document", "feature": "document", "status": "passed", "score": 0.94 },
{ "node_id": "node_liveness", "feature": "liveness", "status": "passed", "score": 0.91 },
{ "node_id": "node_face", "feature": "faceMatch", "status": "passed", "score": 0.88 },
{ "node_id": "node_poa", "feature": "poa", "status": "skipped", "score": null }
]
}

workflow:

FieldTypeDescription
idstringWorkflow id
version_idstringThe published version the session was pinned to
versionnumberVersion number inside the workflow, starting at 1

checks has one entry per feature step of that workflow version:

FieldTypeDescription
node_idstringId of the step in the workflow graph. Stable within one workflow version
featurestringWhich check it is, see the list below
statusstringpending, passed, failed, skipped or error. skipped means the check did not run for this session (for example, no selfie was uploaded or no proof of address)
scorenumber | nullConfidence score for checks that produce one; null when the check has no score or did not run

feature values:

ValueCheck
documentDocument reading and validation
livenessLiveness of the selfie
faceMatchSelfie against the document portrait
faceReverifyFace re-verification of a returning person
poaProof of Address
vaultReuseReuse of an identity that was verified before
amlAML screening

When these fields can be missing:

  • The session ran without a workflow: workflow is null and checks is [].
  • Flonk could not read the workflow data when it built the event: both fields are left out. Treat a missing field as "unknown", not as "no workflow".
  • Use feature values you know and ignore the rest, so a check added later does not break your code.

Only ids, the version number, statuses and scores are sent. Workflow names, issue codes and branch decisions stay in the dashboard.

verification.status_changed

Sent when a verification's status changes. Two kinds of change use this event:

  • Reviewer decision — status is approved or rejected, made by an admin from the dashboard or as the outcome of manual review. A rejection carries rejection_reason and reviewed_by; previous_status is manual_review.
  • Automatic rejection — status is rejected with previous_status: "processing" and no reviewed_by: the checks reached a verdict no review could change, so the session was never queued. rejection_reason is a machine-readable code — today only DOCUMENT_EXPIRED (the document is past its expiry date; the holder needs a new one and must start a new session).
  • Review entry (informational) — status is manual_review or action_required, fired the moment automated checks route the session there. No decision has been made yet; previous_status is processing. An action_required entry additionally carries next_action (resubmit_front / resubmit_back). These entry events are additive — ignore them if you only act on the final decision.

A manual-review approval does not use this event — it fires verification.completed instead. Only rejections (reviewer or automatic) and the informational review-entry events above arrive as verification.status_changed.

Additional fields in data.object:

FieldTypeDescription
previous_statusstringStatus before the change (e.g. completed, manual_review, processing)
rejection_reasonstring?Reason for rejection (only when status is rejected) — free text from a reviewer, or a code such as DOCUMENT_EXPIRED from an automatic rejection
reviewed_bystring?Identifier of who made the decision (admin email or reviewer role); absent on an automatic rejection
next_actionstring?On an action_required entry: the side to re-upload — resubmit_front or resubmit_back
json
{
"id": "evt_1234567891",
"type": "verification.status_changed",
"created": 1640995300,
"livemode": true,
"data": {
"object": {
"id": "verification_attempt_id",
"client_id": "user_1761052168279",
"status": "rejected",
"confidence": 0.95,
"document_type": "passport",
"extracted_data": {
"full_name": "JOHN DOE",
"first_name": "JOHN",
"last_name": "DOE"
},
"previous_status": "completed",
"rejection_reason": "Document expired",
"reviewed_by": "admin@company.com",
"created_at": "2025-10-21T13:10:10.584Z"
}
}
}

verification.updated

Sent when an admin manually edits verification data (document fields, uploads new files) from the dashboard.

Additional fields in data.object:

FieldTypeDescription
updated_atstringISO 8601 timestamp of the update
updated_bystring?Email of the admin who made the edit
extracted_dataobjectUpdated extracted data (issue_date, expiry_date, place_of_birth, …). document_number is not included — see the note below.
json
{
"id": "evt_1234567892",
"type": "verification.updated",
"created": 1640995400,
"livemode": true,
"data": {
"object": {
"id": "verification_attempt_id",
"client_id": "user_1761052168279",
"status": "completed",
"document_type": "passport",
"extracted_data": {
"full_name": "JOHN DOE",
"first_name": "JOHN",
"last_name": "DOE",
"date_of_birth": "1990-01-15",
"nationality": "UKR",
"sex": "M",
"issue_date": "2020-01-01",
"expiry_date": "2030-01-01",
"place_of_birth": "Kyiv"
},
"created_at": "2025-10-21T13:10:10.584Z",
"updated_at": "2026-03-31T12:00:00.000Z",
"updated_by": "admin@company.com",
"test_mode": false
}
}
}

verification.aml_alert

Sent when ongoing AML monitoring finds a new possible match for a person you verified earlier. It fires only when Ongoing monitoring is enabled. The verification itself stays completed; review the new match in the dashboard.

Fields in data.object:

FieldTypeDescription
idstringThe verification attempt ID (same as verification_attempt_id).
statusstringVerification status. Stays completed.
document_typestringType of the verified document.
extracted_dataobjectAlways {}. Alerts carry no personal data.
created_atstringISO 8601 timestamp when the alert was created.
test_modebooleantrue for test-mode sessions.
client_idstringYour client ID for the person, when you set one.
client_metadataobjectThe metadata you passed when creating the session, when you set one.
session_idstringThe session that was verified.
verification_attempt_idstringThe verification attempt the match belongs to.
amlobjectUpdated AML summary, now including the new match.
alert.new_hitsnumberHow many new matches this alert found.
alert.categoriesstring[]Categories of the new matches (SANCTION, PEP, CRIMINAL, OTHER).
alert.detected_atstringISO 8601 timestamp of the detection.
json
{
"id": "evt_1234567893",
"type": "verification.aml_alert",
"created": 1640995500,
"livemode": true,
"data": {
"object": {
"id": "verification_attempt_id",
"status": "completed",
"document_type": "passport",
"extracted_data": {},
"created_at": "2026-11-12T08:30:01.000Z",
"test_mode": false,
"client_id": "client_42",
"session_id": "sess_1234567890",
"verification_attempt_id": "verification_attempt_id",
"aml": {
"status": "hit",
"provider": "dilisense",
"checked_at": "2026-10-05T12:04:30.000Z",
"total_hits": 2,
"matched_hits": 1,
"cleared_hits": 0,
"confirmed_hits": 0,
"categories": ["PEP"]
},
"alert": {
"new_hits": 1,
"categories": ["PEP"],
"detected_at": "2026-11-12T08:30:00.000Z"
}
}
}
}

This event is additive; integrators that do not use monitoring never receive it.

Handling Event Types

typescript
const event = flonk.webhooks.constructEvent(rawBody, signature, secret);
switch (event.type) {
case 'verification.completed':
// Automated AI decision
await handleAutomatedVerification(event.data.object);
break;
case 'verification.status_changed':
// Admin manual decision
await handleAdminDecision(event.data.object);
break;
case 'verification.updated':
// Admin edited verification data
await handleDataUpdate(event.data.object);
break;
case 'verification.aml_alert':
// Ongoing monitoring found a new possible match
await handleAmlAlert(event.data.object);
break;
}

Signature Verification (Security)

Important: Always verify webhook signature for security!

typescript
import { FlonkKYCServer } from '@flonkid/kyc/server';
const flonk = new FlonkKYCServer({
secretKey: process.env.FLONK_SECRET_KEY!,
});
// Automatically detects signature format (t=,v1= or sha256=)
const event = flonk.webhooks.constructEvent(
rawBody, // raw request body as string
signatureHeader, // X-Signature header (recommended) or X-Signature-256
webhookSecret, // your webhook secret
);
console.log(event.type); // 'verification.completed', 'verification.status_changed', 'verification.updated', or 'verification.aml_alert'
console.log(event.data.object.id); // verification ID

Manual Verification

If you verify without the SDK, use a constant-time comparison — === on the signature string leaks how many leading characters matched via timing and is exploitable. Use crypto.timingSafeEqual:

typescript
import crypto from 'crypto';
function verifyWebhookSignature(
payload: string,
signature: string,
secret: string
): boolean {
const expected =
'sha256=' + crypto.createHmac('sha256', secret).update(payload).digest('hex');
// Constant-time compare. HMAC both sides so the buffers are equal length
// regardless of input, then timingSafeEqual — no early length/return branch.
const key = crypto.randomBytes(32);
const a = crypto.createHmac('sha256', key).update(signature).digest();
const b = crypto.createHmac('sha256', key).update(expected).digest();
return crypto.timingSafeEqual(a, b);
}

To check the timestamped X-Signature by hand: read t and v1 from the header, compute HMAC-SHA256 (hex) of the string {t}.{rawBody} with your webhook secret, compare it to v1 in constant time, and reject the request if t is more than 5 minutes from your clock.

Prefer the SDK's constructEvent — it does exactly this for you and also handles the timestamped t=,v1= format.

Best Practices

1. Idempotency

Flonk delivers at-least-once (see Retry Logic), so the same event can arrive more than once. Dedupe by event.id — store the ids you've processed and skip ones you've already seen. This is the same pattern you'd use for Stripe; keep it in your own durable store, separate from the signature check.

A unique index on the event id (atomic, durable) is the simplest:

typescript
app.post('/api/kyc/webhook', async (req, res) => {
const event = flonk.webhooks.constructEvent(req.rawBody, req.headers['x-signature'], secret);
try {
await db.webhookEvents.create({ data: { eventId: event.id } }); // unique constraint
} catch (e) {
if (isUniqueViolation(e)) return res.status(200).end(); // already processed
throw e;
}
await processWebhook(event);
res.status(200).end();
});

Or with Redis — SET NX returns null when the key already existed:

typescript
const fresh = await redis.set(`whk:${event.id}`, '1', 'PX', 6 * 60_000, 'NX');
if (fresh === null) return res.status(200).end(); // retry — already handled

2. Quick Response

Respond quickly (< 5 seconds), process asynchronously:

typescript
@Post('webhooks/flonk')
async handleWebhook(@Body() payload: any) {
// Quick validation
if (!this.verifySignature(payload)) {
throw new UnauthorizedException();
}
// Add to processing queue
await this.queue.add('process-webhook', payload);
// Respond immediately
return { received: true };
}

3. Retry Logic

Flonk makes up to 8 delivery attempts per event: the first immediately, then one every 5 minutes — a flat interval, not exponential backoff. So the last attempt lands roughly 35 minutes after the first.

SettingValue
Attempts8 (1 immediate + 7 retries)
Interval5 minutes, flat
Per-attempt timeout30 seconds
Counts as deliveredany 2xx
Retriedany other status, plus timeouts and connection errors
Never retried400 and 401 — we read those as "this endpoint will never accept it"

After the 8th failed attempt the delivery is marked dead and stops on its own. Dead and failed deliveries can be replayed by hand from Settings → Webhooks in the dashboard, optionally against a different URL — a replay sends the original body, so your signature check still passes.

Because a slow endpoint burns attempts, respond 200 first and process afterwards (see Quick Response).

5. Delivery status and failed deliveries

Every real event is stored as a delivery, and you can follow it in Settings → Webhooks. A delivery is in one of these states:

StatusMeaning
pendingQueued, not tried yet (or queued again after a manual retry)
in_flightBeing sent right now
succeededYour endpoint answered 2xx
failedThe last attempt failed and another attempt is scheduled
deadNo more attempts: the 8th attempt failed, or your endpoint answered 400 / 401

The status filter also has Open failures: the failed and dead deliveries that still need attention.

When something is failing, a red box at the top of the tab says how many deliveries are open. It has two buttons:

  • Show failed opens the Open failures list. Open a delivery to see each attempt and your endpoint's answer, then Retry it to the project URL or to a custom URL.
  • Not relevant hides the current failures for the whole team. The alert comes back only when a new delivery fails or someone retries one by hand.

The same alert appears on the dashboard overview. Only people who can manage project settings see it and can retry, and only for projects that have a webhook URL set. If you do not use webhooks, remove the endpoint URLs (Sandbox and Production in Settings → API, and the test URL in Settings → Test Mode): nothing is sent, and the alert stops.

Test mode webhooks

Sessions made with a sk_test_* key send webhooks too, so you can test your receiver end to end. They have livemode: false, are signed with the test webhook secret, and go to the Test Webhook URL from Settings → Test Mode (if none is set, the environment's endpoint URL is used).

To check your endpoint without creating a session, set the Test Webhook URL in Settings → Test Mode and press Send Test Webhook. It sends one sample verification.completed event (id starting evt_test_, livemode: false) with both signature headers, and shows you whether your endpoint answered 2xx.

A test ping is sent once and is not stored as a delivery. It does not appear in Settings → Webhooks, is not retried, and cannot be replayed from there. Use the dashboard message, or your own logs, to see how it went.

4. Logging

Log all received webhooks. The fields live on the event, not on a wrapper:

typescript
logger.info('Webhook received', {
eventId: event.id, // 'evt_...' — also the X-Event-Id header
type: event.type, // 'verification.completed'
verificationId: event.data.object.id,
clientId: event.data.object.client_id,
created: event.created, // Unix seconds
});