Skip to main content

Collecting the Responses

The startFaceRecon function returns a Promise that resolves with an already-typed object — unlike startOcr, there is no need to call JSON.parse().

Promise resolution

type FACE_RECON_RETURN_VALUES = {
image_key: string;
device_scan_session_id: string;
};
AttributeTypeDescription
image_keystringIdentification key of the provided image, which can be used in any other service of the QI Tech system. Important: store this value to send in the validation APIs (e.g. the Onboarding API).
device_scan_session_idstringIdentification key of the device scan session performed internally by the Face Recognition SDK, which can be used in any other service of the QI Tech system.
{
"image_key": "5d0f0e1c-8f9e-4b6c-9c3d-2f8a1b4e7c10",
"device_scan_session_id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"
}

Promise rejection

On failure, the Promise is rejected with an object of type FACE_RECON_ERROR:

type FACE_RECON_ERROR = {
status_code: number;
reason: string;
description: string;
};
AttributeTypeDescription
status_codenumberHTTP status code of the error.
reasonstringIdentifier of the error reason.
descriptionstringDetailed description of the error.

Most common errors

reasonstatus_codedescription
INVALID_TOKEN401Authentication token expired or invalid — the client_session_key is invalid or has expired.
USER_CANCELED0User canceled FaceRecon. — the user interrupted the flow before completing it.

Handling example

startFaceRecon(CAAS_ENVIRONMENT.SANDBOX, clientSessionKey)
.then((response) => {
console.log('Image Key: ', response.image_key);
console.log('Device Scan Session Id: ', response.device_scan_session_id);
})
.catch((error) => {
// Optional: type assertion (cast) to FACE_RECON_ERROR.
// Recommended to ensure type safety in TypeScript.
const reconError = error as FACE_RECON_ERROR;

console.error('Status:', reconError.status_code);
console.error('Reason:', reconError.reason);
console.error('Description:', reconError.description);
});