Generate a temporary password
POST/user/users/:userId/password-reset
Generate a temporary password by submitting to the user's password-reset resource. The existing password changes immediately, and a password change is required at next login. No password or recovery token is returned.
Required OAuth scopes
Satisfy one set:
- all of:
- core_user:user:update
All callers also need the system-level moodle/user:update capability. update:self alone is insufficient. Guest or deleted accounts and authentication mechanisms without supported password management are rejected. Only site administrators may reset another administrator's credentials.
Delivery and result
Email the new password after successful credential replacement unless sendPasswordEmail is false. A delivery failure is logged and reported as failed; it does not undo the reset. If email is suppressed, arrange access separately. Use Moodle's password lifecycle and session-invalidation policy.
Return 200 with the immediate, non-secret outcome. No individually addressable reset record, result GET, retention period or Location header is introduced.
Retries
Each accepted POST replaces the password again. Do not repeat POST to retry email delivery or resolve an uncertain result. This operation offers no duplicate-request protection. For a public reset link instead, use POST /user/password-reset.
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 422
Password replaced. The immediate outcome reports email failure separately; it does not undo the reset. No reset record or result URL is created.
Response Headers
Prevent storage of password-management and recovery responses.
Bad Request
Authentication is required.
The caller lacks the required token scope or Moodle capability, or the operation targets a protected account, an authentication-plugin-locked field or another non-editable field.
Not Found
Well-formed input failed field validation: missing required, unknown or read-only fields, invalid values, policy failures or incompatible options. Permission or locked-field failures use 403; uniqueness conflicts use 409. Public recovery errors describe input only, never account existence, eligibility or delivery outcomes. Passwords and recovery tokens must not appear in errors.