Skip to content

AI Integration Skill

Biometry Integration Architect — API v2

This document is an instruction set for AI coding agents (Claude, GPT, Copilot, etc.) building biometric verification against Biometry API v2. Feed it to your agent as context before it writes integration code.

Machine-readable contract, if your agent can fetch a URL: https://api.biometrysolutions.com/api-gateway/v2/openapi.json.

Working on an existing v1 integration? See the v1 skill and the migration guide.


System architecture

Biometry follows an API proxy pattern. The customer’s backend proxies all Biometry calls; the frontend never calls Biometry directly, because the API token is a secret that must not reach a browser or mobile binary.

┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ Customer Frontend │ │ Customer Backend │ │ Biometry API │
│ │ │ │ │ │
│ Web SDK / Flutter │────▶│ /api/verify │────▶│ /api-gateway/v2/ │
│ (captures media) │◀────│ (holds API token) │◀────│ │
└─────────────────────┘ └──────────────────────┘ └─────────────────────┘

Base URL: https://api.biometrysolutions.com/api-gateway/v2

Other prefixes you will need (unversioned, shared with v1):

  • /api-consent — consent records (API v1; on v2 use PUT /v2/users/{user_id}/consents)
  • /api-transactions — transaction history
  • /api-projects — API key management
  • /api-auth — Console user auth; not part of a backend integration

SDK proxy mode routes

When the Web SDK (3.1.0+) or Flutter SDK (2.1.0+) runs in proxy mode (baseUrl set, no token), it calls the customer backend at baseUrl plus the API v2 path without the /api-gateway/v2 prefix. The backend owns these routes and forwards each one, rebuilt and with the API token added, to the same path under /api-gateway/v2:

MethodBackend route (<baseUrl> plus)Forwards toNote
POST/sessions/api-gateway/v2/sessions?warmup=true kept
POST/sessions/{session_id}/end/api-gateway/v2/sessions/{session_id}/end
POST/liveness/api-gateway/v2/liveness
POST/face-verify/api-gateway/v2/face-verify
POST/voice-verify/api-gateway/v2/voice-verify
POST/face-match/api-gateway/v2/face-match
POST/enrollments/face/api-gateway/v2/enrollments/face
POST/enrollments/voice/api-gateway/v2/enrollments/voice
POST/documents/check/api-gateway/v2/documents/check
POST/deepfake/checks/api-gateway/v2/deepfake/checksFlutter only
POST/consents/{consent_id}/approve/{user_id}/api-gateway/v2/consents/{consent_id}/approve/{user_id}Flutter only
GET/consents/my-approvals/{user_id}/api-gateway/v2/consents/my-approvals/{user_id}Flutter only

To use other route names, pass paths to the SDK (Web: paths: { endSession: '/biometry-sessions/{session_id}/finish' }; Flutter: paths: {ProxyOperation.endSession: '/biometry-sessions/{session_id}/finish'}) and serve the same names on the backend. A renamed route still forwards to the default Biometry path: in the reference proxy, change only the first path of the route’s ROUTES entry and keep its upstream, for example route('POST', '/biometry-sessions/:session_id/finish', { upstream: '/sessions/:session_id/end', ... }). ROUTES writes a path parameter as :session_id; the SDK’s paths writes the same parameter as {session_id}. The backend records consent itself with PUT /api-gateway/v2/users/{user_id}/consents (the Web SDK’s consent methods and Flutter’s giveConsent, getConsentStatus and revokeConsent throw in proxy mode) and owns the liveness challenge. Full rules and a reference proxy: Backend proxy.


Authentication

One header, on every call:

Authorization: Bearer <API_TOKEN>

The token is a JWT minted in the Console. It encodes project_id, the enabled services, and optionally a scoring system ID. It does not expire — it is valid until revoked, so treat it as a long-lived secret: environment variable or secret manager, one token per application, never in version control.

A second credential exists — the Console user session — and it is not interchangeable. These endpoints require it and will reject an API token with 401: scoring systems (/v2/scoring-systems/*), webhooks (/v2/webhooks/*), consent document authoring, GET /v2/sessions, DELETE /v2/users/{user_id}. If your task says “create a webhook”, the answer is the Console, not the API token.


The two rules that differ most from v1

1. Identity is user_id, in the body. No X-User-Fullname. user_id is an opaque, caller-chosen string, 3–128 chars matching ^[A-Za-z0-9._:@-]+$, unique inside the project. Use the customer’s own primary key, a UUID, or a hash — never a person’s name, and never anything with spaces (it will be rejected with 400).

2. Parameters live in the body. File-carrying endpoints are multipart/form-data with a single JSON part named request alongside the file parts. The v1 business headers (X-User-Fullname, X-Session-ID, X-Action-Trigger, X-Use-Prefilled-Video, X-Inhouse-Docauth, X-Inhouse-MRZ) are stripped on v2 routes — sending them does nothing.

Headers that remain headers: Authorization, X-Request-Id, X-Client-App, X-Client-Version, X-App-Version, X-Device-Info, X-Geo-Location.


Response envelope

Every response, success or failure:

{
"data": { },
"decision": { "status": "pass", "score": 87.5, "reasons": [] },
"meta": { "request_id": "b6f0…", "message": "video processed successfully" }
}
{
"error": { "code": "invalid_request", "message": "user_id is required" },
"meta": { "request_id": "b6f0…" }
}
  • data — endpoint payload. Omitted when there is nothing to return.
  • decision — present only when a scoring system was evaluated. status ∈ pass | refer | fail.
  • meta.request_id — always present. Log it on every call; it is what Biometry support traces.

Service results are keyed by public service name: face_liveness_detection, active_speaker_detection, visual_speech_recognition, face_recognition, voice_recognition. Each value is { code, description, result, score } with score on a 0–100 scale. Only services enabled on the token appear.


Failure modes an agent must handle

These are the three things naive generated code gets wrong.

1. 200 does not mean “passed”. Services run in parallel and report independently. A failed one appears as {"error": "…"} under its own key while the HTTP status stays 200:

{ "data": { "face_recognition": { "error": "there is no enrolled face for this person" } } }

Always inspect each service entry and the decision, never the status alone.

2. Rejected enrollment is also 200. POST /v2/enrollments/face returns meta.message: "failed to enroll face" with a non-zero data.enrollment_result.code (1 no face / too small / bad quality, 2 more than one face, 3 face not centered). Voice returns data.status of error or qafailed. Branch on those, not on the status code.

3. Missing consent silently drops services. Face Recognition and Voice Recognition require authorization consent. Without it they are removed from the call and the response carries the header X-Removed-Services: true — you get a 200 with the identity check simply absent. Check consent up front or check that header.

Error codes to branch on: invalid_request (400), invalid_api_key / invalid_token (401), service_not_enabled (403), forbidden (403, includes missing consent), not_found (404), conflict (409), unprocessable_entity (422), internal_error (500, retry with backoff).


Record both consents with one v2 call, keyed by the same user_id as every other call:

PUT /api-gateway/v2/users/{user_id}/consents
Authorization: Bearer <API_TOKEN>
Content-Type: application/json
{ "authorization": true, "storage": true }

authorization gates recognition and enrollment; storage gates enrollment only. true gives, false withdraws, an omitted field is unchanged, and a repeat is a no-op. An optional session_id (your project’s session, not another user’s) shows the consent with that session in the Console. GET on the same path returns { "user_id", "authorization", "storage" } (both false if never given).

/v2/consents/* is a different feature (custom consent templates): approving one does not unlock enrollment. The v1 consent service (POST /api-consent/consent, /api-consent/strg-consent with your user_id as user_fullname) records the same consents; you only need it to read the consent history (GET /api-consent/history).


Integration flow: verify a returning user

1. Pre-flight — is this user enrolled?

GET /api-gateway/v2/users/{user_id}
{ "data": { "user_id": "…", "enrollments": { "face": true, "voice": false }, "voice_phrases": [] } }

An unknown user is not a 404 — it returns enrollments all false. Use this to route between onboarding and login, and to skip a check the user cannot pass. Batch form: GET /v2/users?ids=a,b,c (max 100).

2. Start a session

POST /api-gateway/v2/sessions → { "data": { "session_id": "…" } }
POST /api-gateway/v2/sessions?warmup=true (pre-warms ML services)

A session is one verification attempt: it groups the calls, stores the liveness video so later calls can reuse it, and its end returns the attempt’s decision. Pass session_id in the request part of every subsequent call. Sessions are single-use and last 24 hours: after end (or expiry), calls naming the session get 409 session_ended / session_expired. Start a new session for every attempt. See Sessions.

3. Liveness

POST /api-gateway/v2/liveness
Content-Type: multipart/form-data
request = {"user_id":"…","session_id":"…","phrase":"48719352"}
video = <file>

Returns face_liveness_detection, active_speaker_detection, visual_speech_recognition. phrase is required — it is what Visual Speech Recognition compares its transcript against. Optional fields in request: vocabulary, trigger, services.exclude (array of service keys).

The phrase is a challenge the integrator’s backend issues (see Liveness challenge):

  • Generate 8 distinct digits from 1–9 with a CSPRNG (crypto.randomInt, crypto/rand), never Math.random. 8 because the voice engine needs at least 7 recognised words; no 0 because it is said several ways.
  • Store it server-side against the login attempt (key from server-side session state, not a client-supplied id), expire it within 5 minutes, rate-limit issuing, and use it once (atomic read-and-delete, e.g. Redis GETDEL).
  • Send only the digits to the device for display (challengeDigits on the React/Angular face recorder, Biometry.setChallenge in Flutter), with about 10 s of recording.
  • Send the backend’s stored copy as phrase to /v2/liveness and /v2/voice-verify. Never use a phrase the device returns: that lets a pre-recorded video be replayed with matching digits. /v2/face-verify takes no phrase (face recognition only).
  • v2 accepts the digit string ("48719352") or the words; v1 /process-video needs the words.

4. Identity

POST /api-gateway/v2/face-verify request = {"user_id","session_id","use_session_video":true}
POST /api-gateway/v2/voice-verify request = {"user_id","phrase","session_id","use_session_video":true}

Each compares against the user’s enrolled template and returns its own decision (pass/fail/refer), which covers only that call. Run them only for modalities the pre-flight said are enrolled.

In a session they must run on the liveness media. Either set use_session_video: true and send no file (above), or send the same file the liveness call got (video / voice part). Other media is refused with 400 media_mismatch; a call not bound to a passing liveness on the same media returns refer. A repeated liveness call replaces the media and discards earlier face/voice results (named in meta.warnings): run face-verify and voice-verify again after the last liveness. Never generate code that sends a separately recorded audio file to voice-verify inside a session.

5. End the session

POST /api-gateway/v2/sessions/{id}/end
{ "phone_number": "+996700000000" } ← optional SIM-swap check

The end response is the verification result. It scores the session’s liveness, face-verify and voice-verify results together and returns decision.status = accept, refer or reject, with decision.reasons. A face match that ran in the session counts too (a failed match gives reject). Document checks are not included: in an onboarding flow, check that response too.

{ "decision": { "status": "accept", "score": 0.93 }, "meta": { "message": "session ended successfully" } }

Grant access only on accept; do not compose the per-call decisions yourself. A failed critical check gives reject; a critical step that never ran (or whose result a later liveness discarded) gives refer. Calling end again returns the same stored decision.


Integration flow: document onboarding

POST /api-gateway/v2/sessions → session_id
POST /api-gateway/v2/documents/check
request = {"session_id":"…","provider":"inhouse"} (provider/mrz_provider optional)
document = <file> → extracted fields + portrait_photo
POST /api-gateway/v2/liveness request+video → anti-spoof results
POST /api-gateway/v2/face-match
request = {"user_id":"…","session_id":"…","use_session_video":true}
reference_image = <document portrait> → match against the stored video
POST /api-gateway/v2/enrollments/face (optional, for future logins)
request = {"user_id":"…","session_id":"…","use_session_video":true} → enrolls from the session's video
POST /api-gateway/v2/sessions/{id}/end

use_session_video is honoured by /v2/face-match, /v2/face-verify, /v2/voice-verify and /v2/enrollments/face — every one of them reuses the video the liveness step stored on the session, so the capture is uploaded once. In a session, face match must run on the liveness media like face-verify (other media → 400 media_mismatch), and enrolling from the session video needs a passing liveness and no failed face match (else 409 liveness_not_passed / face_match_failed). /v2/enrollments/voice does not take it: a voiceprint needs several distinct recordings. Enroll before /v2/sessions/{id}/end; once the session is closed its video can no longer be enrolled from.


Asynchronous: deepfake detection

POST /api-gateway/v2/deepfake/checks request = {"user_id","session_id"}, video = <file> → 201
GET /api-gateway/v2/deepfake/checks/{request_id}

The ID to poll with is data.metadata.request_id from the 201 response — not meta.request_id, which identifies the HTTP call. Poll until data.status is completed or failed; the verdict is data.result.prediction (real / fake) with confidence and score. Or register a webhook and skip polling.


Checklist before shipping generated code

  • API token read from the environment on the backend; never sent to a client
  • user_id is opaque and stable, matches ^[A-Za-z0-9._:@-]{3,128}$, and is the same value used for consent
  • Consent collected before enrollment (authorization and storage) and before recognition (authorization)
  • Parameters in the request JSON part, not in X-* headers
  • Every response checked per service, not by HTTP status
  • meta.request_id logged on every call
  • session_id passed to every call in one attempt, and the session ended on both success and failure paths
  • Retries only on 5xx, with backoff; never retry a successful enrollment or deepfake submission
  • Media captured client-side via the Web or Flutter SDK and forwarded through your backend

Reference

TopicPage
Envelope, identity model, service keysAPI v2 Overview
End-to-end curl walkthroughv2 Quick Start
Every error codeError catalog
Verification endpoints in fullVerification
How the verdict is computedScoring Systems
Reading results backTransactions