> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/identity-api/identity-api-reference/users/users-management/enroll-user.md).

# Enroll User

Registers a new user's face in the collection. The userId must be unique within the collection.

### Endpoint

```
PUT /users/{userId}
```

### Authentication

| Type    | Location | Name          |
| ------- | -------- | ------------- |
| API Key | Header   | **x-api-key** |

### Request body

**Content-Type:** `application/json`

#### Route parameters

| Parameter | Type   | Required | Description                                                                   |
| --------- | ------ | -------- | ----------------------------------------------------------------------------- |
| `userId`  | string | **Yes**  | Unique identifier for the user. This ID must be unique within the collection. |

#### Parameters

| Parameter | Type   | Required | Description                                                                                                                                                |
| --------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `face`    | string | **Yes**  | Image of the user's face **encoded in Base64** or tokenized. For open images, the supported formats are **JPEG** and **PNG**. Maximum supported size: 5MB. |

#### Request example

```json
{
  "face": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
}
```

### Responses

#### `200` Success

User successfully registered. This response does not include a body.

#### `400` Bad Request

#### Response example: duplicate userId

```json
{
  "status": 400,
  "title": "Bad Request",
  "detail": "Invalid request.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400",
  "errors": ["the provided userId already exists"]
}
```

#### Response example: invalid face image

```json
{
  "status": 400,
  "title": "Bad Request",
  "detail": "Invalid request.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400",
  "errors": ["no face was detected in the provided image"]
}
```

#### `401` Unauthorized

```json
{
  "message": "Unauthorized"
}
```

#### `403` Forbidden

```json
{
  "Message": "User is not authorized to access this resource with an explicit deny"
}
```

#### `404` Not Found

```json
{
  "status": 404,
  "title": "Not Found",
  "detail": "The server can't find the requested resource.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404"
}
```
