change-password.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [role="xpack"]
  2. [[security-api-change-password]]
  3. === Change passwords API
  4. ++++
  5. <titleabbrev>Change passwords</titleabbrev>
  6. ++++
  7. Changes the passwords of users in the native realm and built-in users.
  8. [[security-api-change-password-request]]
  9. ==== {api-request-title}
  10. `POST /_security/user/_password` +
  11. `POST /_security/user/<username>/_password`
  12. [[security-api-change-password-prereqs]]
  13. ==== {api-prereq-title}
  14. * Every user can change their own password. Users with the `manage_security`
  15. privilege can change passwords of other users.
  16. [[security-api-change-password-desc]]
  17. ==== {api-description-title}
  18. You can use the <<security-api-put-user,create user API>> to update everything
  19. but a user's `username` and `password`. This API changes a user's password.
  20. For more information about the native realm, see
  21. {stack-ov}/realms.html[Realms] and <<configuring-native-realm>>.
  22. [[security-api-change-password-path-params]]
  23. ==== {api-path-parms-title}
  24. `username`::
  25. (Optional, string) The user whose password you want to change. If you do not specify
  26. this parameter, the password is changed for the current user.
  27. [[security-api-change-password-request-body]]
  28. ==== {api-request-body-title}
  29. `password`::
  30. (Required, string) The new password value.
  31. [[security-api-change-password-example]]
  32. ==== {api-examples-title}
  33. The following example updates the password for the `jacknich` user:
  34. [source,js]
  35. --------------------------------------------------
  36. POST /_security/user/jacknich/_password
  37. {
  38. "password" : "s3cr3t"
  39. }
  40. --------------------------------------------------
  41. // CONSOLE
  42. // TEST[setup:jacknich_user]
  43. A successful call returns an empty JSON structure.
  44. [source,js]
  45. --------------------------------------------------
  46. {}
  47. --------------------------------------------------
  48. // TESTRESPONSE