Spec-Zone.ru › Elasticsearch 8
›Elasticsearch Guide [8.17] ›REST APIs ›Security APIs

Get users API

New API reference

For the most up-to-date API details, refer to Security APIs.

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

Request

GET /_security/user

GET /_security/user/<username>

Prerequisites

  • To use this API, you must have at least the read_security cluster privilege.

Description

For more information about the native realm, see Realms and Native user authentication.

Path parameters

username
(Optional, string) 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.

Query parameters

with_profile_uid
(Optional, boolean) Determines whether to retrieve the user profile uid, if exists, for the users. Defaults to false.

Response body

A successful call returns an array of users with the JSON representation of the users. Note that user passwords are not included.

Response codes

If the user is not defined in the native realm, the request 404s.

Examples

To retrieve a native user, submit a GET request to the /_security/user/<username> endpoint:

resp = client.security.get_user(
    username="jacknich",
)
print(resp)
const response = await client.security.getUser({
  username: "jacknich",
});
console.log(response);
GET /_security/user/jacknich
{
  "jacknich": {
    "username": "jacknich",
    "roles": [
      "admin", "other_role1"
    ],
    "full_name": "Jack Nicholson",
    "email": "jacknich@example.com",
    "metadata": { "intelligence" : 7 },
    "enabled": true
  }
}

To retrieve the user profile_uid as part of the response:

resp = client.security.get_user(
    username="jacknich",
    with_profile_uid=True,
)
print(resp)
const response = await client.security.getUser({
  username: "jacknich",
  with_profile_uid: "true",
});
console.log(response);
GET /_security/user/jacknich?with_profile_uid=true
{
  "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"
  }
}

Omit the username to retrieve all users:

resp = client.security.get_user()
print(resp)
const response = await client.security.getUser();
console.log(response);
GET /_security/user

© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-get-user.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API