get-users.asciidoc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [role="xpack"]
  2. [[security-api-get-user]]
  3. === Get users API
  4. ++++
  5. <titleabbrev>Get users</titleabbrev>
  6. ++++
  7. Retrieves information about users in the native realm and built-in users.
  8. [[security-api-get-user-request]]
  9. ==== {api-request-title}
  10. `GET /_security/user` +
  11. `GET /_security/user/<username>`
  12. [[security-api-get-user-prereqs]]
  13. ==== {api-prereq-title}
  14. * To use this API, you must have at least the `read_security` cluster privilege.
  15. [[security-api-get-user-desc]]
  16. ==== {api-description-title}
  17. For more information about the native realm, see
  18. <<realms>> and <<native-realm>>.
  19. [[security-api-get-user-path-params]]
  20. ==== {api-path-parms-title}
  21. `username`::
  22. (Optional, string) An identifier for the user. You can specify multiple
  23. usernames as a comma-separated list. If you omit this parameter, the API
  24. retrieves information about all users.
  25. [[security-api-get-user-response-body]]
  26. ==== {api-response-body-title}
  27. A successful call returns an array of users with the JSON representation of the
  28. users. Note that user passwords are not included.
  29. [[security-api-get-user-response-codes]]
  30. ==== {api-response-codes-title}
  31. If the user is not defined in the `native` realm, the request 404s.
  32. [[security-api-get-user-example]]
  33. ==== {api-examples-title}
  34. To retrieve a native user, submit a GET request to the `/_security/user/<username>`
  35. endpoint:
  36. [source,console]
  37. --------------------------------------------------
  38. GET /_security/user/jacknich
  39. --------------------------------------------------
  40. // TEST[setup:jacknich_user]
  41. [source,console-result]
  42. --------------------------------------------------
  43. {
  44. "jacknich": {
  45. "username": "jacknich",
  46. "roles": [
  47. "admin", "other_role1"
  48. ],
  49. "full_name": "Jack Nicholson",
  50. "email": "jacknich@example.com",
  51. "metadata": { "intelligence" : 7 },
  52. "enabled": true
  53. }
  54. }
  55. --------------------------------------------------
  56. Omit the username to retrieve all users:
  57. [source,console]
  58. --------------------------------------------------
  59. GET /_security/user
  60. --------------------------------------------------
  61. // TEST[continued]