Field note / Java
Designing KYC Onboarding Around Your Identity-Verification Vendor
Identity verification is asynchronous, unreliable and out of your control. How to model onboarding states, handle webhooks safely and keep customers moving when the vendor doesn't.
Most KYC integrations start from the vendor’s quickstart: create a verification session, redirect the customer, wait for the “approved” webhook, open the account. It works in the demo. Then production arrives with documents that need manual review, webhooks that come twice or not at all, and a vendor outage on the busiest day of the month.
The vendor is a dependency you don’t control, in the middle of the flow that decides whether you get a customer. The onboarding design has to assume it will be slow, ambiguous and occasionally down.
Model the states, not the happy path
The quickstart has two outcomes. Real verification has many more, and the customer, your support team and your compliance team all need to know which one they’re in. Make them explicit:
public enum VerificationStatus {
NOT_STARTED,
SUBMITTED, // customer finished the vendor flow
IN_REVIEW, // vendor or our staff reviewing manually
NEEDS_MORE_INFO, // customer must resubmit something
APPROVED,
REJECTED,
EXPIRED; // customer abandoned, or the session timed out
private static final Map<VerificationStatus, Set<VerificationStatus>> ALLOWED = Map.of(
NOT_STARTED, Set.of(SUBMITTED, EXPIRED),
SUBMITTED, Set.of(IN_REVIEW, NEEDS_MORE_INFO, APPROVED, REJECTED),
IN_REVIEW, Set.of(NEEDS_MORE_INFO, APPROVED, REJECTED),
NEEDS_MORE_INFO, Set.of(SUBMITTED, EXPIRED),
APPROVED, Set.of(),
REJECTED, Set.of(),
EXPIRED, Set.of(NOT_STARTED)
);
public boolean canMoveTo(VerificationStatus next) {
return ALLOWED.get(this).contains(next);
}
}
Two things this buys you immediately:
- Terminal states are terminal. A late
IN_REVIEWwebhook can’t drag an approved customer back into review. - Every screen has a state to render. The customer sees “we’re reviewing your documents” instead of a spinner, and staff see a queue of
IN_REVIEWandNEEDS_MORE_INFOapplications instead of searching logs.
Keep the vendor’s own status vocabulary in a mapping layer. When you switch vendors, or add a second one for a country the first doesn’t cover, your onboarding states don’t change.
Treat webhooks as untrusted, duplicated and out of order
A verification webhook is an HTTP request from the internet claiming a customer passed KYC. Handle it like that.
Verify the signature first. Every serious vendor signs webhook payloads. Check the signature against the raw request body before parsing anything, and reject requests with old timestamps to block replays.
Store, acknowledge, then process. Write the raw event to a table and return 200 fast. Process it in the background. If processing fails, you still have the event, and the vendor doesn’t retry into a slow endpoint.
@PostMapping("/webhooks/identity")
public ResponseEntity<Void> receive(@RequestBody String body,
@RequestHeader("X-Signature") String signature) {
if (!signatures.isValid(body, signature)) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
}
VendorEvent event = parser.parse(body);
if (events.saveIfNew(event.id(), event.applicantRef(), body)) {
processor.enqueue(event.id());
}
return ResponseEntity.ok().build();
}
Deduplicate on the vendor’s event id. saveIfNew is a unique constraint on the event id, not a lookup. Vendors retry deliveries; the second copy should be a no-op.
Expect events out of order. “Approved” can arrive before “in review”. The state machine above handles most of this: an approved application ignores a late in-review event. For anything ambiguous, fetch the current status from the vendor’s API instead of trusting the event payload.
Don’t depend on webhooks arriving at all
Webhooks get lost: a misconfigured endpoint after a deploy, an expired certificate, a vendor-side incident. If your onboarding only advances on webhooks, a lost one leaves a customer stuck forever, and they’ll tell you about it on social media before your monitoring does.
Add a reconciliation job. Every few minutes, find applications that have been SUBMITTED or IN_REVIEW longer than expected, ask the vendor’s API for their current status, and apply it through the same state machine. Webhooks become the fast path; reconciliation is the guarantee.
Alert on the age of the oldest open application, not on individual webhook failures. “Twelve customers have been in review for over a day” is actionable. “Webhook returned 500” usually isn’t.
Plan for the vendor being down
When the vendor’s session API fails, you have a choice the quickstart never mentions:
- Block the customer: show an error and hope they come back. Many won’t.
- Let them continue: collect everything you can (personal details, product choice), save the application as
NOT_STARTEDfor verification, and send a link to finish when the vendor is back.
For most products the second option keeps far more customers, as long as nothing irreversible happens before verification. No account funding, no card issuance, no access to money movement until the application is APPROVED. The state machine is what makes that rule enforceable instead of a convention.
Make manual review a real workflow
Some percentage of applications will always need a human: blurry documents, name mismatches, edge-case nationalities. That isn’t a vendor failure; it’s the job. Build for it:
- A staff queue of applications in
IN_REVIEWandNEEDS_MORE_INFO, oldest first. - The vendor’s reasons and risk signals shown next to the application, not in a separate dashboard.
- Staff decisions recorded with who, when and why. Compliance will ask.
- A clear path for “ask the customer for a new document” that moves the application to
NEEDS_MORE_INFOand notifies them.
Keep personal data out of everything else
Identity documents and selfies are the most sensitive data most companies ever hold. Where you can, let the vendor store the images and keep only their reference ids and the decision. Never log payloads; log the applicant reference, the event id and the state transition. Restrict who can open documents in the back office, and audit who did.
The checklist
- Explicit verification states with allowed transitions; terminal states stay terminal.
- Vendor statuses mapped in one layer, so the vendor is replaceable.
- Webhooks: verify signatures, store raw, deduplicate on event id, process async.
- A reconciliation job that recovers from lost webhooks, plus alerts on application age.
- A defined behavior for vendor downtime, with nothing irreversible before approval.
- Manual review as a first-class queue with an audit trail.
- Minimal personal data stored and none in logs.
The vendor’s job is to verify identities. Yours is everything around it: the states, the retries, the gaps and the people. That’s where onboarding conversion and compliance risk are actually decided.