> ## Documentation Index
> Fetch the complete documentation index at: https://docs.adherecompliance.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Face Comparison

> Compare two face images to determine whether they belong to the same person.

The Face Comparison endpoint uses biometric analysis to compare two face images and returns a confidence score indicating whether they depict the same individual. Use this for identity verification during onboarding or transaction approval.

Before comparing, the provider runs an anti-spoofing check on `selfie_url`; if that check fails, no comparison is attempted and the response says so explicitly — see [200 OK — rejected by anti-spoofing check](#200-ok-rejected-by-anti-spoofing-check-no-comparison-performed) below.

## Endpoint

```
POST /api/onboarding/biometrics/face/comparison
```

## Request

### Headers

| Header | Value | Required |
| - | - | - |
| `x-access-token` | Your API secret key | Yes |
| `Content-Type` | `application/json` | Yes |

### Body Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `image_url` | string | Yes | URL of the reference ID photo or database face image |
| `selfie_url` | string | Yes | URL of the live selfie to compare against the reference |

### Example

```bash cURL theme={null}
curl -X POST "https://adhere-api.smartcomply.com/api/onboarding/biometrics/face/comparison" \
  -H "x-access-token: YOUR_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/id_photo.jpg",
    "selfie_url": "https://example.com/selfie.jpg"
  }'
```

```javascript Node.js theme={null}
const response = await fetch(
  "https://adhere-api.smartcomply.com/api/onboarding/biometrics/face/comparison",
  {
    method: "POST",
    headers: {
      "x-access-token": "YOUR_SECRET_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      image_url: "https://example.com/id_photo.jpg",
      selfie_url: "https://example.com/selfie.jpg",
    }),
  }
);
const data = await response.json();
```

```python Python theme={null}
import requests

response = requests.post(
    "https://adhere-api.smartcomply.com/api/onboarding/biometrics/face/comparison",
    headers={
        "x-access-token": "YOUR_SECRET_KEY",
        "Content-Type": "application/json",
    },
    json={
        "image_url": "https://example.com/id_photo.jpg",
        "selfie_url": "https://example.com/selfie.jpg",
    },
)
data = response.json()
```

## Response

### 200 OK

| Field | Type | Description |
| - | - | - |
| `data.status` | boolean | `true` if the faces match, `false` if they do not |
| `data.response_code` | string | `"00"` indicates a successful comparison |
| `data.message` | string | Human-readable match result |
| `data.confidence` | integer | Match confidence percentage (0–100) |
| `data.record_id` | number | Internal record ID for this check |

```json theme={null}
{
  "status": "success",
  "data": {
    "status": true,
    "response_code": "00",
    "message": "Face Match",
    "confidence": 100,
    "record_id": 76981
  },
  "message": "Face comparison completed successfully"
}
```

A `data.status` of `false` indicates the faces do not match. Use `data.confidence` to apply your own threshold for acceptance (e.g., require `>= 80` for a positive match).

### 200 OK — rejected by anti-spoofing check (no comparison performed)

Before comparing the two images, the provider runs its own anti-spoofing check on `selfie_url` — this catches a photo of a photo, a screen replay, or another spoofed submission. If `selfie_url` fails that check, the comparison itself never runs, and the response explains why in `data.message` rather than simply saying the faces don't match. `data.confidence` is `0` in this case since no match score was produced.

> [!NOTE]
>
> This check runs even though `selfie_url` is a still image, not a video — the message text below still refers to "the submitted video" because it's shared with the Face Liveness Check endpoint's internal wording. Treat this response the same way regardless of whether you submitted a photo or a video as the selfie.

```json theme={null}
{
  "status": "failed",
  "data": {
    "status": false,
    "response_code": "01",
    "message": "Liveness check failed — the submitted video did not pass the liveness/anti-spoofing check, so no face comparison was performed.",
    "confidence": 0
  },
  "message": "Liveness check failed — the submitted video did not pass the liveness/anti-spoofing check, so no face comparison was performed."
}
```

Ask the user for a clearer selfie (better lighting, no screen/photo in frame) and resubmit — this is not the same failure as a genuine face mismatch, and retrying with a better-quality selfie of the same person is the correct next step.

### 400 Bad Request

Returned when one or both image URLs are missing, inaccessible, or do not contain a detectable face.

```json theme={null}
{
  "status": "failed",
  "data": [],
  "message": "Could not process one or both images"
}
```

### 401 Unauthorized

```json theme={null}
{
  "status": "failed",
  "message": "Authentication credentials were not provided."
}
```


## OpenAPI

````yaml POST /api/onboarding/biometrics/face/comparison
openapi: 3.0.3
info:
  title: Adhere API
  description: >-
    Identity verification, credit checks, transaction monitoring, and loan fraud
    detection across Africa.
  version: 3.0.0
servers:
  - url: https://adhere-api.smartcomply.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Nigeria KYC
  - name: Kenya KYC
  - name: Ghana KYC
  - name: Rwanda KYC
  - name: Uganda KYC
  - name: Document Verification
  - name: Biometrics
  - name: Individual Credit
  - name: Business Credit
  - name: Transaction Monitoring
  - name: Transaction Screening
  - name: Transaction KYC
  - name: Loan Fraud
  - name: User Journey
paths:
  /api/onboarding/biometrics/face/comparison:
    post:
      tags:
        - Biometrics
      summary: Face Comparison
      operationId: faceComparison
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - image_url
                - selfie_url
              properties:
                image_url:
                  type: string
                  description: URL of the reference ID photo
                selfie_url:
                  type: string
                  description: URL of the selfie image
      responses:
        '200':
          description: >-
            Comparison ran to completion. This includes the anti-spoofing
            rejection case below — the provider still returns HTTP 200 with
            status "failed" when selfie_url fails its own liveness check before
            any comparison is attempted.
          content:
            application/json:
              examples:
                facesMatch:
                  summary: Faces match
                  value:
                    status: success
                    data:
                      status: true
                      response_code: '00'
                      message: Face Match
                      confidence: 100
                      record_id: 76981
                    message: Face comparison completed successfully
                facesDoNotMatch:
                  summary: Faces do not match
                  value:
                    status: failed
                    data:
                      status: false
                      response_code: '01'
                      message: Face Mismatch
                      confidence: 42
                      record_id: 76982
                    message: Face comparison failed — faces do not match
                antiSpoofingRejected:
                  summary: Rejected by anti-spoofing check (no comparison performed)
                  value:
                    status: failed
                    data:
                      status: false
                      response_code: '01'
                      message: >-
                        Liveness check failed — the submitted video did not pass
                        the liveness/anti-spoofing check, so no face comparison
                        was performed.
                      confidence: 0
                    message: >-
                      Liveness check failed — the submitted video did not pass
                      the liveness/anti-spoofing check, so no face comparison
                      was performed.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: failed
              data:
                type: array
                items: {}
              message:
                type: string
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: failed
              message:
                type: string
                example: Authentication credentials were not provided.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-access-token
      description: Your Adhere API secret key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.