Set a user's password
PATCH/user/users/:userId/password
Set an explicit password through a supported authentication plugin. The password must meet site policy and is never returned. This operation is for administrators; users change their own passwords through Moodle's web UI, where plugin-specific change flows and platform security controls are applied. A self-service password API is not provided.
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 change another administrator's credentials.
Behaviour
Set requirePasswordChange only when you also want to change that persistent account requirement; omission preserves it. Use Moodle's password lifecycle and session-invalidation policy. No credential email is sent. Repeating the same desired state does not intentionally generate another password, but history or policy checks may reject a repeat. Do not retry blindly after an uncertain result.
To generate a temporary password instead, use POST /user/users/{userId}/password-reset. This write-only resource has no readable password representation or ETag; conditional writes are not offered.
Request
Responses
- 204
- 400
- 401
- 403
- 404
- 422
Password updated. No response body or password is returned.
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.