---
type: api
title: Get users
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-security-get-user
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-security-get-user
products:
  - Elasticsearch
---

# Get users


## Paths

- `GET` `/_security/user/{username}`
- `GET` `/_security/user`

#### Path parameters

- `username` (union string | string[]) — optional, leave it out to use `/_security/user`
  An identifier for the user. You can specify multiple usernames as a comma-separated list. If you omit this parameter, the API retrieves information about all users.

## Description

Get information about users in the native realm and built-in users.

## Required authorization

- Cluster privileges: `read_security`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `with_profile_uid` (boolean · default: false) — optional
  Determines whether to retrieve the user profile UID, if it exists, for the users.

## Response

`application/json`

- `<string>` (object)
  - `email` (union string) — nullable
    One of: `string`
  - `full_name` (union string) — nullable
  - `metadata` (object)
  - `roles` (string[])
  - `username` (string)
  - `enabled` (boolean)
  - `profile_uid` (string)
## Code examples

#### Console

```console
GET /_security/user/jacknich?with_profile_uid=true
```

#### JavaScript

```javascript
const response = await client.security.getUser({
  username: "jacknich",
  with_profile_uid: "true",
});
```

#### Python

```python
resp = client.security.get_user(
    username="jacknich",
    with_profile_uid=True,
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_security/user/jacknich?with_profile_uid=true" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().getUser(g -> g
    .username("jacknich")
    .withProfileUid(true)
);
```

#### C#

```c#
var response = await client.Security
    .GetUserAsync(d1 => d1
        .Username(["jacknich"])
        .WithProfileUid(true)
    );
```

#### PHP

```php
$resp = $client->security()->getUser([
    "username" => "jacknich",
    "with_profile_uid" => "true",
]);
```

#### Ruby

```ruby
response = client.security.get_user(
  username: "jacknich",
  with_profile_uid: "true"
)
```

## Response examples

#### Security get user response example1

A successful response from `GET /_security/user/jacknich?with_profile_uid=true`. It includes the user `profile_uid` as part of the response.

```json
{
  "jacknich": {
    "username": "jacknich",
    "roles": [
      "admin", "other_role1"
    ],
    "full_name": "Jack Nicholson",
    "email": "jacknich@example.com",
    "metadata": { "intelligence" : 7 },
    "enabled": true,
    "profile_uid": "u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0"
  }
}
```

