get-users.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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-query-params]]
  26. ==== {api-query-parms-title}
  27. `with_profile_uid`::
  28. (Optional, boolean) Determines whether to retrieve the <<user-profile,user profile>> `uid`,
  29. if exists, for the users. Defaults to `false`.
  30. [[security-api-get-user-response-body]]
  31. ==== {api-response-body-title}
  32. A successful call returns an array of users with the JSON representation of the
  33. users. Note that user passwords are not included.
  34. [[security-api-get-user-response-codes]]
  35. ==== {api-response-codes-title}
  36. If the user is not defined in the `native` realm, the request 404s.
  37. [[security-api-get-user-example]]
  38. ==== {api-examples-title}
  39. To retrieve a native user, submit a GET request to the `/_security/user/<username>`
  40. endpoint:
  41. [source,console]
  42. --------------------------------------------------
  43. GET /_security/user/jacknich
  44. --------------------------------------------------
  45. // TEST[setup:jacknich_user]
  46. [source,console-result]
  47. --------------------------------------------------
  48. {
  49. "jacknich": {
  50. "username": "jacknich",
  51. "roles": [
  52. "admin", "other_role1"
  53. ],
  54. "full_name": "Jack Nicholson",
  55. "email": "jacknich@example.com",
  56. "metadata": { "intelligence" : 7 },
  57. "enabled": true
  58. }
  59. }
  60. --------------------------------------------------
  61. To retrieve the user `profile_uid` as part of the response:
  62. [source,console]
  63. --------------------------------------------------
  64. GET /_security/user/jacknich?with_profile_uid=true
  65. --------------------------------------------------
  66. // TEST[continued]
  67. [source,console-result]
  68. --------------------------------------------------
  69. {
  70. "jacknich": {
  71. "username": "jacknich",
  72. "roles": [
  73. "admin", "other_role1"
  74. ],
  75. "full_name": "Jack Nicholson",
  76. "email": "jacknich@example.com",
  77. "metadata": { "intelligence" : 7 },
  78. "enabled": true,
  79. "profile_uid": "u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0"
  80. }
  81. }
  82. --------------------------------------------------
  83. Omit the username to retrieve all users:
  84. [source,console]
  85. --------------------------------------------------
  86. GET /_security/user
  87. --------------------------------------------------
  88. // TEST[continued]