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

# Authenticate User (1:1)

> Match a live face against one enrolled subject in a collection.

<div className="dj-endpoint">
  <span className={`dj-method dj-method-post`}>POST</span>
  <code>/api/v1/face/authenticate</code>
</div>

Compare a live face to the face already enrolled for a `subject_id` in a collection. This is a 1:1 check — you must know which subject you are authenticating.

## Headers

| Header          | Required | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| `Authorization` | Yes      | Your app's secret key, sent as-is — *not* `Bearer`. |
| `AppId`         | Yes      | The App ID from your dashboard.                     |
| `Content-Type`  | Yes      | `application/json`                                  |

## Body parameters

| Parameter         | Type   | Required | Description                                                                          |
| ----------------- | ------ | -------- | ------------------------------------------------------------------------------------ |
| `face.image`      | string | Yes      | Face image as a URL or a Base64 string (strip any `data:image/jpeg;base64,` prefix). |
| `face.image_type` | string | Yes      | How `face.image` is encoded: `url` or `base64`.                                      |
| `subject_id`      | string | Yes      | The enrolled subject to compare against.                                             |
| `collection_id`   | string | Yes      | The collection that holds the enrolled face.                                         |

## Response

Returns an `entity` with a boolean `match`, a `similarity` score, the `confidence_band`, the `threshold_used`, the enrolled `subject_id`, how many faces are enrolled for that subject, and the `matched_face_id`.

| Field             | Type    | Description                                                               |
| ----------------- | ------- | ------------------------------------------------------------------------- |
| `match`           | boolean | `true` when `similarity` is at or above `threshold_used`.                 |
| `similarity`      | number  | Face-match score from `0` to `1`.                                         |
| `confidence_band` | string  | Confidence in the match, e.g. `low`, `medium`, or `high`.                 |
| `threshold_used`  | number  | Similarity cutoff applied for this comparison.                            |
| `subject_id`      | string  | The enrolled subject that was compared. Echoes the `subject_id` you sent. |
| `enrolled_count`  | number  | Number of faces enrolled for that subject.                                |
| `matched_face_id` | string  | Identifier of the enrolled face that was compared.                        |

## Errors

| Code  | Meaning                                                                                       |
| ----- | --------------------------------------------------------------------------------------------- |
| `400` | Bad request — a required field is missing or the image is malformed.                          |
| `401` | Unauthorized — check your key and `AppId` (no `Bearer` prefix).                               |
| `402` | Insufficient wallet balance. [Fund your wallet](/api-reference/core-concepts/wallet-billing). |
| `404` | No enrolled face found for that `subject_id` in the collection.                               |
| `429` | Too many requests — back off and retry.                                                       |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.dojah.io/api/v1/face/authenticate" \
    -H "Authorization: {{secret_key}}" \
    -H "AppId: {{app_id}}" \
    -H "Content-Type: application/json" \
    -d '{
      "face": {
        "image": "https://images.dojah.io/face.jpg",
        "image_type": "url"
      },
      "subject_id": "1234576",
      "collection_id": "90570273-6652-4ff1-8054-f20b4e73cbd2"
    }'
  ```

  ```js Node.js theme={null}
  const res = await fetch("https://api.dojah.io/api/v1/face/authenticate", {
    method: "POST",
    headers: {
      Authorization: process.env.DOJAH_SECRET_KEY,
      AppId: process.env.DOJAH_APP_ID,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      face: {
        image: "https://images.dojah.io/face.jpg",
        image_type: "url"
      },
      subject_id: "1234576",
      collection_id: "90570273-6652-4ff1-8054-f20b4e73cbd2"
    }),
  });
  const data = await res.json();
  ```

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

  res = requests.post(
      "https://api.dojah.io/api/v1/face/authenticate",
      headers={
          "Authorization": os.environ["DOJAH_SECRET_KEY"],
          "AppId": os.environ["DOJAH_APP_ID"],
      },
      json={
          "face": {
              "image": "https://images.dojah.io/face.jpg",
              "image_type": "url"
          },
          "subject_id": "1234576",
          "collection_id": "90570273-6652-4ff1-8054-f20b4e73cbd2"
      },
  )
  data = res.json()
  ```
</RequestExample>

<ResponseExample>
  ```json POST /api/v1/face/authenticate theme={null}
  {
    "entity": {
      "match": false,
      "similarity": 0.055,
      "confidence_band": "low",
      "threshold_used": 0.62,
      "subject_id": "1234576",
      "enrolled_count": 2,
      "matched_face_id": "face-sandbox-001"
    }
  }
  ```
</ResponseExample>
