Skip to main content

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​

Password updated. No response body or password is returned.

Response Headers
    Cache-Control

    Prevent storage of password-management and recovery responses.