Skip to main content

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:

typemeaning
validation_errormalformed request — the message names the field
invalid_keyunknown, revoked, or wrong-mode credential
feature_disabledthe feature isn't enabled for your tenant
unsupported_image_formatnot a decodable JPEG/PNG/WEBP/TIFF/BMP/HEIC
low_quality_face / no_face_detected / multiple_faces_detected_in_image_bface-input problems — prompt a retake
challenge_action_not_detectedliveness challenge action wasn't performed
rate_limitedback 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.