Verify a face (1:1)
Confirm that the person in front of the camera is the subject you expect.
Prerequisites
- A previously enrolled
enrolleeId. - An initialised
SladeIDinstance and a<video>element.
Full example
import { SladeID } from '@sladeid/slade-id-sdk';
const sdk = new SladeID({
middlewareUrl: 'https://id.example.com',
clientSecret: '<ClientSecret>',
});
const video = document.querySelector<HTMLVideoElement>('#camera')!;
const session = sdk.createFaceSession(video, { requireLiveness: true });
session.on('captured', async ({ result }) => {
const verdict = await sdk.matchFace('subject-123', result);
if (verdict.matched) {
console.log(`match: distance=${verdict.distance} threshold=${verdict.threshold}`);
} else {
console.log(`no match: distance=${verdict.distance}`);
}
});
await session.start();Response shape (matched):
{
"matched": true,
"distance": 0.31,
"threshold": 0.45,
"logId": "0e89...-...",
"raw": { "...": "untouched" }
}distance is cosine distance — 0 is identical, around 1 is orthogonal. logId is the audit row UUID; surface it in support tickets.
What can go wrong
matched: falseis not an error. It is a normal result. Do not catch it as an exception.- HTTP 422 from the backend — older backend revisions returned
422for a mismatch. Current revisions return200withmatched: false. If you see422, confirm the backend version with your Slade ID contact before treating it as a mismatch.