Error handling
Every failure throws a typed EkycError carrying the HTTP status and the parsed API error envelope:
import { EkycError } from '@drukverify/ekyc-sdk-js';
try {
await client.fraud.detect(image);
} catch (e) {
if (e instanceof EkycError) {
console.log(e.status); // e.g. 400
const err = (e.body as any)?.error;
console.log(err?.type); // stable machine-readable code
console.log(err?.message); // human-readable detail
console.log(err?.request_id); // quote this to support
console.log(err?.doc_url); // documentation for this error
}
}
The API's error contract is { error: { type, message, request_id, doc_url } }. Codes you should branch on include:
| type | meaning |
|---|---|
validation_error | malformed request — the message names the field |
invalid_key | unknown, revoked, or wrong-mode credential |
feature_disabled | the feature isn't enabled for your tenant |
unsupported_image_format | not a decodable JPEG/PNG/WEBP/TIFF/BMP/HEIC |
low_quality_face / no_face_detected / multiple_faces_detected_in_image_b | face-input problems — prompt a retake |
challenge_action_not_detected | liveness challenge action wasn't performed |
rate_limited | back off and retry |
Timeouts surface as EkycError with status: 0 and message Request timed out (configurable via timeout). A request_id accompanies every response — logging it alongside your own correlation IDs makes support turnaround immediate.
The full error catalogue is in the Errors concept page.