Compare Faces
Server-to-Server
Compare Faces
Compare two faces and return a similarity score
POST
Compare Faces
isMatch decision. Typical use: comparing a selfie to the photo on a scanned ID.
Request
Headers
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Your API key |
Content-Type | Yes | multipart/form-data or application/json |
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
source | binary | string | Yes | The first image. For multipart, the file part. For JSON, a base64, base64url, or S3-key string. |
target | binary | string | Yes | The second image. Same input rules as source. |
source as raw multipart bytes and target as a JSON S3 key in a multipart body. See the overview for the shared image rules.
Example request
Response
200 — Success
| Field | Type | Description |
|---|---|---|
isMatch | boolean | True when confidence >= threshold |
confidence | number | Raw similarity score from AWS Rekognition, 0–100 (not normalized) |
threshold | number | Server-side similarity threshold used for isMatch, 0–100 |
sourceFaceDetected | boolean | True when a face was detected in source |
targetFaceDetected | boolean | True when a face was detected in target |
Error responses
| Status | Description |
|---|---|
400 | Invalid body, unsupported image format, or image larger than 15 MB |
401 | Missing or invalid x-api-key |
402 | Insufficient token balance |
403 | A supplied source/target S3 key is not readable by this organization |
429 | Rate limit exceeded |
500 | Unexpected server error — safe to retry with backoff |
Telling failure modes apart
The response shape lets you distinguish three distinctisMatch: false outcomes without a second API call:
| Outcome | confidence | sourceFaceDetected | targetFaceDetected |
|---|---|---|---|
| Both faces found, similarity too low | > 0 | true | true |
| No face in source | 0 | false | true/false |
| No face in target | 0 | true | false |
| No face in either image | 0 | false | false |
sourceFaceDetected is false, a “retake the ID photo” prompt when targetFaceDetected is false, and a “doesn’t match” outcome when both booleans are true but isMatch is false.