Skip to navigation

Liveness check

POST /api/v1/checks/liveness
GET /api/v1/checks/liveness
GET /api/v1/checks/liveness/:id
DELETE /api/v1/checks/liveness/:id

Check one selfie for liveness: whether the face in it is a real person in front of the camera, or a printed photo or a screen held up to it. The answer comes back in the same response: the outcome, a score from 1 to 100, and what was seen. It is the same check Spot Checks runs from the dashboard (Spot Checks → Individual → Liveness), and every check is kept in the same history (checks run here are labelled “API”).

Authentication: Authorization: Bearer sk_… (secret keys only). A selfie is biometric data, so this never belongs in client-side code.

What a single photo can and cannot show

Toden’s passive liveness model reads the face in the photo, exactly as it reads the selfie of a verification. A phone detector looks for a phone touching the face, and the photo is measured for glare, a screen-like pattern, straight edges framing the face, focus, light and how the face is turned.

A single still is weaker evidence than a live capture. A verification also scores a short clip of the person and can ask them to turn their head, which no photo can show. A good print or a high-quality screen can pass a photo check that a live capture would catch, and a photo cannot show a phone being brought up to the camera. Use this check to screen a photo you already hold. Do not use it in place of liveness on a live capture: for that, run a verification.

Upload the selfie, then check it

  1. Upload the photo with POST /api/v1/upload, type selfie. JPEG, PNG or WebP.
  2. Send the mediaId it returns as selfieMediaId within 30 minutes. The upload must be your own, in the same environment (a sandbox key cannot check a production upload), and not already used by a verification.
curl https://api.toden.co/api/v1/upload \
-H "Authorization: Bearer sk_test_…" \
-F "type=selfie" \
-F "file=@./selfie.jpg"
{ "mediaId": "med_3f1c9a7e5b2d4c6a8e0f1b3d5c7a9e2f" }
FieldRequiredDescription
selfieMediaIdyesThe mediaId the upload returned.
requestIdyesYour idempotency key, 8 to 120 characters. A retry with the same value returns the same check with replayed: true, and is neither run nor charged again.
curl -X POST https://api.toden.co/api/v1/checks/liveness \
-H "Authorization: Bearer sk_test_…" \
-H "Content-Type: application/json" \
-d '{ "selfieMediaId": "med_3f1c9a7e5b2d4c6a8e0f1b3d5c7a9e2f", "requestId": "liveness-7f3a2c91" }'
{
"id": "chk_9a2e4c6b8d0f1a3c5e7b9d2f4a6c8e01",
"kind": "liveness",
"outcome": "pass",
"subject": "Selfie",
"input": { "selfieMediaId": "med_3f1c9a7e5b2d4c6a8e0f1b3d5c7a9e2f" },
"result": {
"verdict": "live",
"confidentAttack": false,
"score": 96,
"scoreBands": { "declineBelow": 20, "reviewBelow": 50 },
"realProbability": 0.968,
"threshold": 0.5,
"attackLine": 0.1,
"model": "minifasnet-v2@2.7+v1se@4.0",
"faceFound": true,
"facesInPhoto": 1,
"phone": { "detected": false, "confidence": 0.04, "line": 0.45, "declineAt": 0.6, "acted": true, "model": "yolox-tiny@coco-67" },
"signals": [],
"imageQuality": { "inFocus": true, "wellLit": true, "closeEnough": true, "facing": true, "wholeFace": true },
"reasons": [],
"selfieMediaId": "med_3f1c9a7e5b2d4c6a8e0f1b3d5c7a9e2f",
"checkedAt": "2026-11-20T10:15:02.000Z"
},
"failureCode": null,
"charged": null,
"entityId": null,
"channel": "api",
"createdAt": "2026-11-20T10:15:01.000Z",
"completedAt": "2026-11-20T10:15:02.000Z",
"replayed": false
}

A new check answers 201; a retry with the same requestId answers 200 with the check already run.

Outcomes

The outcome is set cautiously, because a photo is weaker evidence than a live capture:

What was seenOutcome
The model reads a live face, and no phone touches it.pass
The model reads an attack, below the confident-attack line (attackLine).fail
The model reads an attack, above the confident-attack line.review
A phone is seen touching the face, whatever the model read.review
No face in the photo (failureCode no_face).unavailable
The model could not run or could not read the photo (failureCode model_unavailable).unavailable

A phone at or above phone.declineAt declines a verification, but here it is held for review: a still cannot show the phone being brought up to the camera, which is what that line was measured on.

unavailable means the check could not be completed. It was not charged and is never a pass; run it again with a new requestId (and a clearer photo for no_face).

The result

FieldDescription
verdictThe model’s own reading: live when realProbability is at or above threshold, attack under it.
confidentAttackThe attack is below attackLine, so the outcome is fail.
score1 to 100, higher is more confidently a live person: the same scale a verification shows. It is the weaker of the model’s reading and the phone detector’s.
scoreBandsHow to read score: under declineBelow (20) a verification would decline, under reviewBelow (50) it is borderline, from 50 up it is clear.
realProbabilityThe model’s probability, 0 to 1, that the face is a real, present face.
thresholdUnder this probability the model reads an attack (0.5 by default).
attackLineUnder this probability the attack is confident and the check fails (0.1 by default).
modelThe liveness model’s version.
faceFoundAlways true on a result: a photo with no face is unavailable.
facesInPhotoThe person plus anyone else clearly in the photo; null when it could not be counted. Informs only.
phoneThe phone detector’s reading, or null when it could not run: detected (a phone touches the face, at or above line), confidence (0 to 1), line, declineAt (where a verification declines), acted (false when the phone check only records on this deployment and did not change the outcome) and model.
signalsNotes on the image for a reviewer: “Bright glare patch on the face”, “Screen-like pattern on the face”, “Straight edges framing the face”. They inform and never decide the outcome.
imageQualityWhether the photo was good enough to judge (inFocus, wellLit, closeEnough, facing, wholeFace), or null when it could not be measured. Informs only.
reasonsWhy the outcome is not pass: attack (review), confident_attack (fail), phone_in_view (review). Empty on a pass.
selfieMediaIdThe selfie that was checked.
checkedAtWhen the model read the photo.

New fields may be added to result; existing ones are never renamed.

Once the check is answered, the selfie is kept with it, so your team can see the photo on the result in the dashboard. In production it is kept as long as your media retention allows; in sandbox, for 3 days. A check that could not be completed keeps nothing, and the upload expires after 30 minutes.

History

GET /api/v1/checks/liveness lists your liveness checks in this environment, newest first, with outcome, page and pageSize (at most 100) as filters. GET /api/v1/checks/liveness/:id returns one check. DELETE /api/v1/checks/liveness/:id removes it from your history; the delete is soft and nothing is refunded.

Billing

Each check is charged at your Verifications price for Presence Intelligence (Passive), the passive liveness check, in production only. A check that could not be completed (unavailable: no face found, or the model unavailable) is not charged, and a retry with the same requestId is never charged again. Sandbox and development checks are free.

Sandbox

Outside production the model runs for real on your photo, at no charge. There are no test photos with fixed answers, and no canned pass: a deployment without the model answers check_unavailable (or unavailable with model_unavailable) rather than a result it did not read. To see a review or fail, check a photo of a photo, or of a face on a screen.

Errors

ErrorStatusMeaning
invalid_input400selfieMediaId is missing or not a media id, or the requestId is missing or malformed. message says which.
insufficient_credits402Your balance cannot cover the check. Nothing was run or charged.
checks_unavailable403These checks are not switched on for your organisation yet.
spot_checks_disabled403Spot checks are not enabled for your organisation.
request_id_reused409The requestId was used for a different check.
check_in_progress409A check with this requestId is still running.
file_not_found422The selfie was not found, is not yours, is not a selfie upload, was used by a verification, or has expired. Upload it again.
check_unavailable503The liveness model cannot run on this deployment right now. Nothing was charged.