Delete a user
DELETE/user/users/:userId
Delete a Moodle account through the normal account-deletion lifecycle, including enrolment and role cleanup, session invalidation, event emission and authentication-plugin notification. This does not completely erase personal data.
Required OAuth scopes
Satisfy one set:
- all of:
- core_user:user:delete
All callers also need the system-level moodle/user:delete capability.
Restrictions
- Guest accounts, site administrators and your own account cannot be deleted (
403). - Missing or already-deleted users return
404.
Concurrency and result
If-Match is optional and uses the ETag from GET /user/users/{userId}. A mismatch returns 412 without deletion; without If-Match, deletion is unconditional.
Success returns 204 with no body. Repeating the request may return 404; the account remains deleted.
Request
Responses
- 204
- 400
- 401
- 403
- 404
- 412
- 422
The user account was deleted. No response body.
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
Precondition Failed
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.