Warning
This guide is specific to Web SDK 2.x. For Web SDK 1.x, you can find documentation here.
Do not attempt to upgrade or implement without support. Contact your Incode representative to check if you are a candidate for this upgrade.
The Face Match module compares the user's selfie with the face cropped from their ID document and returns a match decision. Runs server-side using images already collected by the session.
This module follows the backend-process pattern with an additional animating state for the result-reveal animation. See the patterns page for the shared lifecycle.
Tag
<incode-face-match> is a standard Web Component. Importing the UI subpath registers the custom element; importing the CSS applies the module's styles.
import '@incodetech/web/face-match';
import '@incodetech/web/face-match/styles.css';
Properties
| Property | Type | Required | Description |
|---|---|---|---|
config |
FaceMatchConfig |
❌ | Configuration options |
onFinish |
() => void |
❌ | Called when the user acknowledges the result |
onError |
(error: string) => void |
❌ | Called when an error occurs |
Configuration
type FaceMatchConfig = {
matchingType?:
| 'selfieVsId'
| 'selfieVsNfc'
| 'idVsNfc'
| 'nfc3Way'
| 'secondId';
disableFaceMatchAnimation?: boolean;
skipFaceMatch?: boolean;
matched?: boolean;
};
| Option | Type | Required | Description |
|---|---|---|---|
matchingType |
FaceMatchVariant |
❌ | Which images to compare. Default 'selfieVsId'. Backend field name matchingType. |
disableFaceMatchAnimation |
boolean |
❌ | When true, skip the reveal animation and auto-advance after fetching the result. The face images are not fetched. Useful for headless / silent flows. Default false. |
skipFaceMatch |
boolean |
❌ | When true, the module completes immediately on mount without fetching or rendering anything. Default false. The Flow orchestrator sets this, not your code — it applies when the ID was captured with no front image, so there is no ID face to compare against. |
matched |
boolean |
❌ | A match result you already have. When set, the module shows it and does not run the match. Use it when the SDK cannot keep the selfie result, for example in a multi-page app. Ignored for matchingType: 'secondId'. See How the match result is obtained. |
State machine
FaceMatchState is a discriminated union over status:
| Status | Description |
|---|---|
idle |
Initial state. |
loading |
Getting the match result and, when the animation is on, the face images. |
animating |
Playing the reveal animation. Skipped when disableFaceMatchAnimation is true. A face image that cannot be read (for example, the session token has no access to images) shows as a gray circle. |
result |
Animation finished; the match result is on state.result.matched. |
finished |
Terminal. |
error |
Fatal error: the match request or the score request failed. A failed face-images request is not an error: the images are null, the circles show gray, and the match result is kept. |
The result state's data:
type FaceMatchResult = {
matched: boolean | null; // true = match, false = no match, null = unknown
liveness: boolean | null; // true = passed, false = failed, null = not available
};
liveness comes from /omni/get/score: the Deepsight multimodal status when the score has one, otherwise the liveness status. OK gives true, WARN and FAIL give false, and no status gives null. The module reads the score only when Allow Score Retrieval is on and config.matched is not set (see How the match result is obtained). In every other case liveness is null.
The result screen shows "Liveness success" or "Liveness failed" under the match result. When liveness is null, it shows no liveness message.
How the match result is obtained
The match result is the face recognition status of the session score. The backend calculates it during /omni/process/face. The source depends on the Allow Score Retrieval setting of your organization:
| Allow Score Retrieval | Source of the result |
|---|---|
| Off | The success field of the /omni/process/face response. /omni/get/score returns 403 to the session token, so the module does not call it. |
| On | /omni/process/face does not return success. The module reads faceRecognition.overall.status from /omni/get/score. |
success is true when faceRecognition.overall.status is OK, and false for all other statuses. From /omni/get/score, OK gives matched: true, FAIL gives false, and WARN or no status gives null. When matched is null, the screen shows no result icon.
When a selfie capture in the same session already ran /omni/process/face and got success, Face Match shows that result and does not run the match again. You do not have to configure this. It works in <incode-flow>, in a headless orchestrated flow, and with standalone Selfie and Face Match modules on the same page. The SDK keeps the result in memory, for the current session token only. A full page load clears it, for example in a multi-page app. Face Match then runs the match itself. The result is the same, but the session makes one more request. To skip that request, pass the result in config.matched. A value in config.matched takes priority over the saved result:
const faceMatch = document.createElement('incode-face-match');
faceMatch.config = { matched: faceMatched }; // the match result you already have
faceMatch.onFinish = () => goToNextPage();
In headless mode, pass the same config to the manager:
import { createFaceMatchManager } from '@incodetech/core/face-match';
const faceMatchManager = createFaceMatchManager({
config: { matched: faceMatched },
});
With matchingType: 'secondId', Face Match always runs its own match, because the selfie matches only against the first ID. It ignores config.matched and the saved result.
When config.matched is not set, Face Match also runs its own match in these cases:
- No selfie capture ran the match. Examples: a Workflow (its Selfie step does not run face matching), or a flow with Authentication instead of Selfie.
- Allow Score Retrieval is on, so there is no
successto reuse.
API methods
| Method | Purpose |
|---|---|
load() |
Get the match result and the face images. |
animationComplete() |
Tell the manager the animation finished (when animating). |
continue() |
Acknowledge the result and finish. |
reset() |
After finished or error, return to idle. |
Plus the universal lifecycle: subscribe, getState, stop.
See also
- Module: Selfie: captures the selfie this module compares against
- Module: ID Capture: captures the ID this module compares against
- Module Patterns → backend-process
- Individual Modules