Getting started
This page gets a working face enrollment running in under ten minutes. It is the only happy path; alternatives live in Guides.
Before you start, read Prerequisites and confirm you have what you need.
1. Install
# pnpm
pnpm add @sladeid/slade-id-sdk --registry=https://npmjs.slade360.co.ke/
# npm
npm install @sladeid/slade-id-sdk --registry=https://npmjs.slade360.co.ke/
# yarn
yarn add @sladeid/slade-id-sdk --registry=https://npmjs.slade360.co.ke/Any additional runtime assets are installed as transitive dependencies.
2. Configure
import { SladeID } from '@sladeid/slade-id-sdk';
const sdk = new SladeID({
middlewareUrl: 'https://id.example.com',
clientSecret: '<ClientSecret>',
});That is the entire required config. Everything else is optional and covered in the configuration reference.
3. Mount the capture surface
<video id="camera" autoplay muted playsinline></video>
<button id="capture">Capture</button>
<pre id="status"></pre>4. Capture and submit
import { SladeID, type FaceCaptureResult } from '@sladeid/slade-id-sdk';
const sdk = new SladeID({
middlewareUrl: 'https://id.example.com',
clientSecret: '<ClientSecret>',
});
const video = document.querySelector<HTMLVideoElement>('#camera')!;
const status = document.querySelector<HTMLPreElement>('#status')!;
const button = document.querySelector<HTMLButtonElement>('#capture')!;
const session = sdk.createFaceSession(video, {
requireLiveness: true,
autoCapture: true,
});
session.on('guidance', (g) => {
status.textContent = `phase: ${g.phase}`;
});
session.on('captured', async ({ result }: { result: FaceCaptureResult }) => {
try {
const enrolled = await sdk.enrollFace('demo-subject-001', result);
status.textContent = `enrolled id=${enrolled.id}`;
} catch (err) {
status.textContent = `error: ${(err as Error).message}`;
}
});
button.addEventListener('click', () => session.start());Expected response shape from enrollFace:
{
"id": "f3c4b2a8-...",
"enrollee": "demo-subject-001",
"createdAt": "2026-05-14T10:00:00Z",
"raw": { "...": "untouched backend payload" }
}What just happened
SladeIDwired up the authenticated transport and the biometrics API for you.createFaceSessionopened the camera, loaded the face landmarker, and started a per-frame guidance loop. See Capture session lifecycle.- The
'captured'event fired once the face passed quality and anti-spoof gates. See Quality scoring and Liveness and anti-spoof. enrollFacesubmitted the capture to the Slade ID backend over HTTPS with your token.