Face Match API
Compares a selfie with a reference face photo and returns a similarity score, whether it passes your threshold, and quality flags for the selfie.
- Source
- Our face recognition model, comparing the two images you send
- Turnaround
- Real time, usually about a second
- Endpoint
- POST /v1/face/match
- Who can use it
- Any business with the user's consent to process their photo for verification.
Overview
Face match answers one question: is the person in this selfie the same person as in this reference photo? The reference can be a PAN or DL photo, the Aadhaar eKYC photo or a DigiLocker document. You get a 0 to 100 score, plus a quality check on the selfie so you can ask for a retake instead of failing someone over a blurry photo.
Good to know
It compares photos only. On its own it does not detect spoofs like printed photos or screens, and old or poor ID photos lower the score.
What you get
- Your thresholdSet a strict pass mark for high-value loans and a softer one for low-risk sign-ups. The response tells you which threshold was used.
- Quality check firstBlur, poor lighting, a tiny face or two faces in frame come back as quality flags, so the user can retake.
- Works with old ID photosPAN and Aadhaar photos are often years old and low resolution. The model is tuned for Indian ID photos, not studio shots.
- Images not keptImages are processed for the request and not retained unless you ask us to store them.
Request
POST https://api.ampletrails.com/v1/face/match
| Field | Type | Status | Description |
|---|---|---|---|
selfie | string | Required | Selfie image as base64 or HTTPS URL |
reference | string | Required | Reference face (ID photo, eKYC photo) as base64 or URL |
threshold | number | Optional | Your pass threshold (0–100); defaults to a recommended value |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
match_score | Similarity score from 0 to 100 | 92.4 |
is_match | Whether the score meets your threshold | true |
threshold_used | Threshold applied to this request | 80 |
selfie_quality | Quality check on the selfie (blur, lighting, face size) | good |
faces_detected | Number of faces found in the selfie | 1 |
Example
curl -X POST https://api.ampletrails.com/v1/face/match \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"selfie": "data:image/jpeg;base64,…", "reference": "data:image/jpeg;base64,…", "threshold": 80, "consent": "Y"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/face/match",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"selfie": "data:image/jpeg;base64,…",
"reference": "data:image/jpeg;base64,…",
"threshold": 80,
"consent": "Y"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/face/match", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"selfie": "data:image/jpeg;base64,…",
"reference": "data:image/jpeg;base64,…",
"threshold": 80,
"consent": "Y"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/face/match");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("AMPLE_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode(["selfie" => "data:image/jpeg;base64,…", "reference" => "data:image/jpeg;base64,…", "threshold" => 80, "consent" => "Y"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"match_score": 92.4,
"is_match": true,
"threshold_used": 80,
"selfie_quality": "good",
"faces_detected": 1
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
Selfie step in KYC
Match the selfie to the eKYC or DigiLocker photo as the last step of digital onboarding.
Payout and login re-checks
Ask for a quick selfie before a large withdrawal or a change of bank account.
Field agent visits
Confirm the customer the agent visited is the applicant on file.
Questions about this API
What threshold should we use?
Start with our recommended default and look at your own data for a few weeks. Most teams send scores just below the pass mark to manual review rather than rejecting them.
Is face match the same as liveness?
No. Face match compares two photos. It doesn't prove the selfie was taken live; someone could hold up a printed photo. Pair it with liveness in our SDK or Video KYC for higher-risk flows.
Does it work with masks, glasses or beards?
Glasses are usually fine. Masks, heavy filters and strong backlight lower the score. The quality flags tell you why.
How big should the images be?
A face of at least 200 pixels across is enough. Very large images slow the call; resize to around 1000 pixels on the long side.
Try the Face Match API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.