Selfie-to-ID Match API
Reads an ID photo, compares its face with a selfie and returns a pass, review or fail verdict with the match score, extracted ID fields and reasons.
- Source
- Our OCR and face recognition models, run on the images you send
- Turnaround
- Real time, a few seconds
- Endpoint
- POST /v1/face/selfie-id
- Who can use it
- Any business with the user's consent to process their selfie and ID image.
Overview
For many products, a selfie plus a photo of an ID is enough KYC. This API does the whole step in one call: it reads the ID with OCR, compares the face on the ID with the selfie and gives you a single verdict with reasons. It's a quick start for self-serve sign-ups, and you can add government verification of the ID number later.
Good to know
It doesn't check the ID number with the issuing authority. A good-quality fake ID with the fraudster's own photo can pass, so add source verification for risky products.
What you get
- One call, one verdictOCR and face match combined, with a clear pass, review or fail.
- Reasons you can act onLow face score, unreadable ID, wrong document type or photocopy, so your app can tell the user what to fix.
- Fields for your recordsThe ID number, name and date of birth come back ready to store or verify further.
- Pass mark you controlSet a face-match threshold per product or risk level.
Request
POST https://api.ampletrails.com/v1/face/selfie-id
| Field | Type | Status | Description |
|---|---|---|---|
selfie | string | Required | Selfie image as base64 or HTTPS URL |
id_image | string | Required | Front of the ID document as base64 or HTTPS URL |
doc_type | string | Optional | Expected document type; auto-detected if omitted |
threshold | number | Optional | Face match pass threshold (0–100) |
Response
Fields inside data. Every response also carries status, request_id and, on errors, message. See error codes.
| Field | Meaning | Example |
|---|---|---|
verdict | Overall result: pass, review or fail | pass |
doc_type | Detected document type | dl |
id_number | Document number read from the ID | DL0420190012345 |
name | Name read from the ID | RAVI KUMAR |
dob | Date of birth read from the ID | 1990-05-14 |
match_score | Selfie vs ID photo similarity from 0 to 100 | 88.7 |
reasons | Why a review or fail verdict was given | [] |
Example
curl -X POST https://api.ampletrails.com/v1/face/selfie-id \
-H "Authorization: Bearer $AMPLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"selfie": "data:image/jpeg;base64,…", "id_image": "data:image/jpeg;base64,…", "doc_type": "dl", "threshold": 80, "consent": "Y"}'import os, requests
resp = requests.post(
"https://api.ampletrails.com/v1/face/selfie-id",
headers={"Authorization": f"Bearer {os.environ['AMPLE_API_KEY']}"},
json={
"selfie": "data:image/jpeg;base64,…",
"id_image": "data:image/jpeg;base64,…",
"doc_type": "dl",
"threshold": 80,
"consent": "Y"
},
timeout=30,
)
resp.raise_for_status()
print(resp.json()["data"])const resp = await fetch("https://api.ampletrails.com/v1/face/selfie-id", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.AMPLE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"selfie": "data:image/jpeg;base64,…",
"id_image": "data:image/jpeg;base64,…",
"doc_type": "dl",
"threshold": 80,
"consent": "Y"
}),
});
const { data } = await resp.json();$ch = curl_init("https://api.ampletrails.com/v1/face/selfie-id");
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,…", "id_image" => "data:image/jpeg;base64,…", "doc_type" => "dl", "threshold" => 80, "consent" => "Y"]),
]);
$data = json_decode(curl_exec($ch), true)["data"];{
"status": "success",
"request_id": "req_7f3a9c21e4",
"data": {
"verdict": "pass",
"doc_type": "dl",
"id_number": "DL0420190012345",
"name": "RAVI KUMAR",
"dob": "1990-05-14",
"match_score": 88.7,
"reasons": "[]"
}
}Example data. The exact field list for your account comes with your sandbox documentation.
Use cases
Marketplace and rental sign-ups
Verify buyers, sellers or tenants in under a minute without a video call.
Gig worker onboarding
Check that the person signing up holds the DL they uploaded.
Age-gated services
Read the date of birth and match the face in one step.
Questions about this API
When does a result go to review?
When the face score is near your threshold, the ID is partly unreadable or quality flags are raised. Reviews are a small share of traffic for most teams.
Should I still verify the ID number?
For regulated or higher-risk products, yes. Run the number through PAN, DL or Voter ID verification after this step.
Which ID types work?
Aadhaar, PAN, Voter ID, DL and passport. PAN and DL photos tend to give the best face match results.
Can users upload from the gallery?
You decide. Our SDK can force a live camera capture, which makes it much harder to reuse someone else's photos.
Try the Selfie-to-ID Match API
Sandbox keys, the full field reference and a Postman collection, usually within a working day.