> For the complete documentation index, see [llms.txt](https://docs.sensecrypt.com/opencv-face-recognition-server/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sensecrypt.com/opencv-face-recognition-server/publish-your-docs/person-management.md).

# Person Management

Following the collection(s) creation, let's start enrolling some person(s) in the collection.

## Add a person

<mark style="color:green;">`PUT`</mark> `/person`

This endpoint is to enroll or update a single person. For bulk person enrollment, please refer to [<mark style="color:red;">PUT/persons</mark>](/opencv-face-recognition-server/publish-your-docs/person-management/bulk-enroll-or-update-persons.md)

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| x-api-key    | `<your-api-key>`   |

**Body**

<table><thead><tr><th>Name</th><th valign="top">Description</th></tr></thead><tbody><tr><td><code>person_id</code></td><td valign="top"><p>Required: Yes </p><p>Type: string</p><p>Example: </p><pre class="language-json"><code class="lang-json"> "person_id": "F12345"
</code></pre><p>Person id must be unique and defined, using same face with different person id will result duplicated record, be aware the person_id is case-sensitive.</p></td></tr><tr><td><code>person_name</code></td><td valign="top"><p>Required: Yes </p><p>Type: string</p><p>Example: </p><pre class="language-json"><code class="lang-json">"person_name": "John Doe"
</code></pre><p>Person name must be defined during enrollment. You can also update an enrolled person's name in later stage, as long the person_id remains the same</p></td></tr><tr><td><code>check_duplicates</code></td><td valign="top"><p>Required: Yes </p><p>Type: boolean</p><p>Default value: false </p><p>Accepted values: false, true</p><pre class="language-json"><code class="lang-json"> "check_duplicates": false
</code></pre><p></p><p>Based on the set similarity score, this feature checks if there is a duplicated enrollment in a collection. If value set as true, enrolling a duplicate person is not allowed.</p></td></tr><tr><td><code>check_liveness</code></td><td valign="top"><p>Required: Yes </p><p>Type: boolean</p><p>Default value: false </p><p>Accepted values: false, true </p><pre class="language-json"><code class="lang-json">"check_liveness": false
</code></pre><p></p><p>If set to true, the liveness check is conducted during the person enrollment. If the person is successfully enrolled, means the face is live, else an error of "ERR_LIVENESS_ERROR" will return if face is not live, and person is not enrolled.<br><br>Check <a href="/opencv-face-recognition-server/publish-your-docs/liveness-detection.md"><mark style="color:red;"><strong>liveness image requirement here</strong></mark></a></p></td></tr><tr><td><code>collection_name</code></td><td valign="top"><p>Required: Yes </p><p>Type: string</p><p>Example: </p><pre class="language-json"><code class="lang-json">"collection_name": "SSAI"
</code></pre><p>Please create a collection first before enrolling person(s). Else an error "The requested entity could not be found." will return</p></td></tr><tr><td><code>duplicate_check_min_similarity</code></td><td valign="top"><p>Required: Yes </p><p>Type: float</p><p>Default value: 0.7</p><p>Example: </p><pre class="language-json"><code class="lang-json">"duplicate_check_min_similarity": 0.7
</code></pre><p></p><p>It's recommended to keep the default value to check the duplicate enrollment. If "check_duplicates" set as false, "duplicate_check_min_similarity" will not be used</p></td></tr><tr><td><code>face_base_64</code></td><td valign="top"><p>Required: Yes </p><p>Type: string</p><p>Example: </p><pre class="language-json"><code class="lang-json">face_base_64": "U2Vjb25kIGltYWdl"
</code></pre><p></p><p>Use base64 encoded string to enroll the face, one image should have only one face</p></td></tr><tr><td><code>face_storage_type</code></td><td valign="top"><p>Required: Yes </p><p>Type: string</p><p>Accepted values: "NoStorage", "StoreThumbnails", "StoreFullImage" </p><p></p><p>Example: </p><pre class="language-json"><code class="lang-json">"face_storage_type": "NoStorage"
</code></pre><p></p><p></p><p>"NoStorage" = do not store any face image "StoreThumbnails" = store only thumbnails (cropped face from the given image) "StoreFullImage" = store full base64 image</p></td></tr><tr><td><code>metadata</code></td><td valign="top"><p>Required: Optional</p><p>Type: dict</p><p>Example: </p><pre class="language-json"><code class="lang-json">  "metadata": {
    "DOB": "2000-01-01",
    "Department": "Operation",
    "Nationality": "Singaporean",
    "Address": "101 Cecil Street, Singapore",
    ...
  }
</code></pre><p></p><p>Metadata is a customizable field that allows to put additional info while enrolling a person. You can add N number customized fields for your use case.</p></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "face_base_64": "string",
  "metadata": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "person_id": "string",
  "person_name": "string"
}
```

{% endtab %}

{% tab title="400" %}
The collection name specified is not valid

```json
{
  "code": "ERR_INVALID_COLLECTION_NAME",
  "message": "Collection names can only contain alphanumeric characters, underscores, hyphens, and periods."
}
```

{% endtab %}

{% tab title="401" %}
Please use an API Key to access this endpoint

```json
{
  "code": "ERR_API_KEY_NOT_PRESENT",
  "message": "The API key is missing from the request."
}
```

{% endtab %}

{% tab title="403" %}
API Key is invalid. Please provide a valid API Key

```json
{
  "code": "ERR_API_KEY_NOT_VALID",
  "message": "The API key is not valid."
}
```

{% endtab %}

{% tab title="404" %}
The collection with the specified name does not exist

```json
{
  "code": "ERR_NOT_FOUND",
  "message": "The requested entity could not be found."
}
```

{% endtab %}

{% tab title="409" %}
Another person with a similar face already exists in the collection

```json
{
  "code": "ERR_PERSON_ALREADY_EXISTS",
  "message": "Another person exists with a similar face. Check metadata for the person_id of the duplicate.",
  "metadata": {
    "person_id": "c96a1bc7-4c4e-497e-897f-c448a4a4be6a"
  }
}
```

{% endtab %}

{% tab title="412" %}
Liveness error. The metadata contains the code that provides specifics about the error

`EYES_CLOSED` || `FACE_CLOSE_TO_BORDER` || `FACE_CROPPED` || `FACE_NOT_LIVE` || `FACE_TOO_CLOSE` || `FACE_ANGLE_TOO_LARGE` || `FACE_IS_OCCLUDED` || `FACE_NOT_FOUND` || `FACE_TOO_SMALL` || `LICENSE_ERROR` || `TOO_MANY_FACES` || `UNKNOWN_ERROR`

```json
{
  "code": "ERR_LIVENESS_ERROR",
  "message": "A liveness error occurred. Please check the supplied image and the error metadata.",
  "metadata": {
    "code": "FACE_NOT_LIVE || .. || UNKNOWN_ERROR"
  }
}
```

{% endtab %}
{% endtabs %}
