Guides
Add 1:1 face verification to your signup flow (safely)
The Compare API is one piece. Here's how to use it without shipping a false sense of security.
TL;DR
To match a user's selfie against their ID photo at signup, use the 1:1 Compare operation: it returns a similarity score you threshold. But face match is one signal, not a complete identity check — it doesn't prove the person is live (vs a printed photo) or that the ID is genuine. A safe flow pairs Compare with liveness, document verification, a manual-review fallback for borderline scores, and clear failure handling. This guide builds that, and is explicit about what it does not cover.
Note: Face comparison alone is not KYC and not proof of identity. It confirms two photos likely show the same face — nothing more. Treat it as one factor alongside liveness and document checks, and get compliance review for regulated onboarding.
Where Compare fits
In an onboarding flow, Compare answers one question: does the selfie match the face on the submitted ID? That's useful — it catches obvious mismatches — but it must sit inside a larger flow that also checks liveness and the document itself.
import os, requests
BASE = "https://api.sightradar.com"
H = {"Authorization": f"Bearer {os.environ['SR_API_KEY']}"}
def verify(selfie_url, id_face_url):
r = requests.post(f"{BASE}/v1/compare", headers=H,
json={"sourceUrl": selfie_url, "targetUrl": id_face_url})
r.raise_for_status()
d = r.json()
if not d.get("face_found"): # no detectable face — ask to retry
return {"decision": "retry"}
score = d["similarity"] # native 0-1 score (Rekognition is 0-100)
if score >= AUTO_PASS: return {"decision": "pass", "score": score}
if score >= REVIEW_MIN: return {"decision": "manual_review", "score": score}
return {"decision": "fail", "score": score}
# Pick these from YOUR labelled data (see the threshold guide) — not a copied
# magic number. A wide review band routes borderline cases to a human review.
AUTO_PASS, REVIEW_MIN = 0.92, 0.80 # illustrative only, on the 0-1 scalePick AUTO_PASS and REVIEW_MIN from your own labelled data — see choosing a face-match threshold. Never copy a magic number from a blog (including this one).
The full flow — Compare is step 3
- Capture consent — the user agrees to biometric processing for verification, and you record it.
- Liveness — confirm a live person, not a photo of a photo or a screen. Compare does not do this.
- Document check — verify the ID is genuine and extract the face crop.
- Face compare — 1:1 match selfie ↔ ID face; get a score.
- Decide — auto-pass, route to manual review, or fail — with a human in the loop for the review band.
- Handle failure — a clear retry path and an alternative for users the automated flow can't verify.
What to store (and delete)
For a pure verification decision you often don't need to persist the biometric at all — Compare and Detect process images in memory and don't store them. Keep the decision and an audit trail, not the raw selfie, unless you have a documented reason and consent to retain it. Deleting what you don't need is the cheapest compliance win there is.
See the Compare and Detect operations in the API reference.
Read the API referenceFrequently asked questions
Can I use a face recognition API for KYC?
Face matching is one component of identity verification, not the whole thing. The Compare operation confirms a selfie likely matches an ID photo, but it does not prove liveness or that the document is genuine. A compliant KYC flow pairs face compare with liveness detection, document verification, a manual-review fallback, and appropriate consent and audit — and should be reviewed by a compliance specialist.
What's the difference between Compare and Search?
Compare is 1:1 — it scores whether two specific images show the same person, which fits selfie-to-ID verification. Search is 1:N — it finds which of many indexed faces match one probe image, which fits find-my-photos. Signup verification uses Compare; photo galleries use Search.
Do I have to store the user's selfie?
Usually not. Compare and Detect process images in memory and don't persist them, so for a pass/fail verification decision you can keep just the decision and an audit trail rather than the raw biometric. Retain the image only with a documented reason and the user's consent.