# Update a user

`PATCH https://api.cademi.com.br/api/v3/users/{user_id}`

Operation ID: `users.update` · API v3

Updates a user. Only the fields supplied in the request are changed. When `settings` is supplied, any setting omitted from it is set to `false`.

To restore a user from the trash, send `deleted: false`.

`status` is derived from the user's activity and is read-only. Including it in the request returns `unknown_field`.

To avoid overwriting a newer version, send the `ETag` returned by the retrieve operation in the `If-Match` header.

Required permissions: `users.update`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `user_id` | path | string | yes |  |

## Request body

Content type: `application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `deleted` | boolean | no |  |
| `document` | string or null | no |  |
| `email` | string (email) | no |  |
| `external_id` | string or null | no |  |
| `name` | string | no |  |
| `phone` | string or null | no |  |
| `settings` | object | no |  |

## Responses

### 200

Returns the updated user.

Body: `data`: User.

Fields of User:

| Field | Type | Required | Description |
|---|---|---|---|
| `access` | string, one of `granted`, `none` | yes |  |
| `created_at` | string (date-time) | yes |  |
| `deleted` | boolean | yes |  |
| `document` | string or null | no |  |
| `email` | string (email) | yes |  |
| `external_id` | string or null | no |  |
| `id` | string | yes |  |
| `name` | string | yes |  |
| `object` | string, one of `user` | yes |  |
| `phone` | string or null | no |  |
| `revision` | string | yes |  |
| `status` | string, one of `active`, `inactive` | yes |  |
| `tags` | array of string | yes |  |
| `updated_at` | string (date-time) | yes |  |

### 401

The credential is missing, malformed, expired, or revoked.

Body: Error.

### 403

The current credentials do not have the permission required by this operation.

Body: Error.

### 404

The user was not found or is not accessible with the current credentials.

Body: Error.

### 409

Another user in the account already uses the same email address or external_id.

Body: Error.

### 412

The user has changed since the supplied revision was retrieved.

Body: Error.

### 422

The request body or query parameters failed validation.

Body: ValidationFailed.

Full schema: https://cademi.dev/openapi/v3.json
