---
type: api
title: Updates the current user
description: Updates the current user.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/operation/operation-update-current-user
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/operation/operation-update-current-user
products:
  - Elastic Cloud Enterprise
---

# Updates the current user

## Paths

- `PATCH` `/user`

- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/authentication#basicauth)
- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/cloud-enterprise/authentication#apikey)

## Description

Updates the current user.

## Request Body

`application/json`

All changes in the specified object are applied to the current user according to the JSON Merge Patch processing rules. Omitting existing fields causes the same values to be reapplied. Specifying a `null` value reverts the field to the default value, or removes the field when no default value exists.

Type: `string`


## Responses

#### `200`

User successfully updated

`application/json`

- `user_name` (string)
  The user's identifier
- `security` ({} UserSecurity)
  A user's security information
  - `roles` ([] string)
    The set of roles assigned to a user
  - `permissions` ([] string)
    The distinct set of permissions allowed by the user's roles. These correspond to operationId values in the OpenAPI definition.
  - `elevated_permissions` ({} ElevatedPermissions)
    A user's elevated permissions status
    - `enabled` (boolean)
      True if the user has elevated permissions
    - `expires_at` (string)
      The time at which the user's elevated permissions expire
  - `password` (string)
    The user's password. Only used when modifying a user.
  - `enabled` (boolean)
    True if the user is enabled
  - `security_realm` ({} UserSecurityRealm)
    The security realm the user belongs to
    - `type` (enum)
      The type of the security realm
      Values: `native`, `ldap`, `saml`, `active_directory`
    - `id` (string)
      The identifier for the security realm
- `metadata` ({} UserMetadata)
  Metadata for a user
  - `created_by` (string)
    The Id of the user that created this user
  - `created_at` (string)
    The date and time when the user was created
  - `updated_by` (string)
    The Id of the user that last updated this user
  - `updated_at` (string)
    The date and time when the user was last updated
  - `first_login_at` (string)
    The date and time when the user first logged in
  - `last_login_at` (string)
    The date and time when the user last logged in
- `full_name` (string)
  The user's optional full name
- `email` (string)
  The user's optional email address
- `builtin` (boolean)
  True if the user is a built-in read-only user
#### `400`

* Some of the provided roles are invalid. (code: `user.roles.invalid`)
* Some of the provided roles are forbidden. (code: `user.roles.forbidden`)
* Trying to set a restricted field. (code: `user.restricted_field`)
* External users cannot be modified. (code: `user.cannot_modify_external`)
* Built-in users cannot be modified. (code: `user.cannot_modify`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `401`

Invalid user authentication. (code: `root.unauthenticated`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `404`

User not found. (code: `user.not_found`)

`application/json`

- `errors` ([] BasicFailedReplyElement)
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` ([] string)
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response Headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code Examples

#### Console

```console
PATCH /user
```

#### curl

```curl
curl -X PATCH "/user"
```

