When to use this vs. hosted sessions
| Use case | Approach |
|---|---|
| Standard KYC onboarding | Hosted sessions — easier, includes UI |
| Custom verification UX | Server-to-server — full control |
| Batch document processing | Server-to-server — no user interaction |
| Backend automation / screening | Server-to-server — programmatic |
| Quick integration, minimal code | Hosted sessions |
Flow overview
Each primitive accepts aFileInput — a Uint8Array/Buffer, a ReadableStream, a base64 / data-URL string, or (on Node, Deno, and Bun) a file path string. The SDK handles presigned upload internally.
Document scan
Extract structured OCR data from an identity document:documentType defaults to 'auto' — the API detects the type. Specifying it can improve accuracy. The result includes fullName, dateOfBirth, documentNumber, expirationDate, issuingCountry, an OCR confidence (0–1), and more. See the Document Scan reference for every field, and the REST Document Scan endpoint for the full schema.
Face detection
Detect a face and get confidence, a bounding box, and landmarks:Face comparison
Compare two face images to check if they’re the same person. Both images upload in parallel for speed:confidence and threshold are reported on a 0–100 scale. REST reference: Face Compare.
Age estimation
Estimate age and gender from a face image:Identity verification (shortcut)
identity.verify() combines document scan + face detection + face comparison into a single orchestrated call. Both images upload in parallel:
document, faceDetection, faceMatch) are always present on a 2xx response, even when verified is false. REST reference: Identity Verify.
Building a custom pipeline
Combine primitives with your own business logic:try/catch to handle typed failures (bad input, auth, rate limits, timeouts) — see Error Handling.