> ## 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.

# Search User (1:N)

> Search a collection for enrolled faces that match a live face.

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

Compare a live face against every enrolled face in a collection and return matches above your `threshold`. This is a 1:N search — you do not need a `subject_id`.

## 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`.                                      |
| `collection_id`   | string | Yes      | The collection to search.                                                            |
| `threshold`       | number | No       | Minimum match score to include in results. Defaults to `0.5`.                        |

## Response

Returns an `entity.hits` array of enrolled faces above your `threshold`, plus how many candidates were examined and the `threshold_used`.

| Field                 | Type   | Description                                                                                 |
| --------------------- | ------ | ------------------------------------------------------------------------------------------- |
| `hits[].subject_id`   | string | Enrolled subject that matched the live face.                                                |
| `hits[].face_id`      | string | Identifier of the enrolled face that matched.                                               |
| `hits[].confidence`   | number | Face-match score from `0` to `100`.                                                         |
| `candidates_examined` | number | Number of enrolled faces compared against the live face.                                    |
| `threshold_used`      | number | Similarity cutoff applied for this search. Echoes the `threshold` you sent, or the default. |

## 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 collection found for the supplied `collection_id`.                                         |
| `429` | Too many requests — back off and retry.                                                       |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.dojah.io/api/v1/face/search" \
    -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"
      },
      "collection_id": "90570273-6652-4ff1-8054-f20b4e73cbd2",
      "threshold": 0.62
    }'
  ```

  ```js Node.js theme={null}
  const res = await fetch("https://api.dojah.io/api/v1/face/search", {
    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"
      },
      collection_id: "90570273-6652-4ff1-8054-f20b4e73cbd2",
      threshold: 0.62
    }),
  });
  const data = await res.json();
  ```

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

  res = requests.post(
      "https://api.dojah.io/api/v1/face/search",
      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"
          },
          "collection_id": "90570273-6652-4ff1-8054-f20b4e73cbd2",
          "threshold": 0.62
      },
  )
  data = res.json()
  ```
</RequestExample>

<ResponseExample>
  ```json POST /api/v1/face/search theme={null}
  {
    "entity": {
      "hits": [
        {
          "subject_id": "subject-sandbox-001",
          "face_id": "face-sandbox-001",
          "confidence": 98.76
        }
      ],
      "candidates_examined": 1,
      "threshold_used": 0.62
    }
  }
  ```
</ResponseExample>
