---
title: "Replace a user's manageable roles. Rejects paid/unknown roles, refuses self-demotion out of admin, and (in the DB tx) refuses to remove the last admin. On success, the target's sessions are invalidated so the change takes effect on their next request."
method: PUT
path: "/api/admin/users/{id}/roles"
tags: ["admin-users"]
---

# Replace a user's manageable roles. Rejects paid/unknown roles, refuses self-demotion out of admin, and (in the DB tx) refuses to remove the last admin. On success, the target's sessions are invalidated so the change takes effect on their next request.

`PUT /api/admin/users/{id}/roles`

## Request

- The document declares no server URL.
- Auth: none declared

## Path parameters

- `id` string, required

## Request body

- SetUserRolesRequest
  - `roles` string[], required: The full desired set of *manageable* roles for the user (see `MANAGEABLE_ROLES`). Paid tiers and the default `user` role are left untouched; passing a non-manageable role is rejected.

## Response `200`

Roles updated

- AdminUserRow
  - `created_at` string, required
  - `display_name` string, required
  - `email` string, required
  - `email_verified` boolean, required
  - `handle` string, nullable
  - `id` string, required
  - `roles` string[], required: All roles the user holds, including the default `user` role and any paid (Stripe-managed) tiers. The UI renders paid roles read-only.

## Other responses

- `400`: Invalid input / non-manageable role / last admin
- `401`: Not authenticated
- `404`: Not found / insufficient permissions

## Changes

- **2026-07-24** `777be1d647f8`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/scholia-study/apis/scholia-api/changes/api/admin/users/:id/roles/put.md)

---

[API](https://skmtc.dev/scholia-study/apis/scholia-api.md) - [All operations](https://skmtc.dev/scholia-study/apis/scholia-api/llms.txt) - [OpenAPI document](https://skmtc.dev/scholia-study/apis/scholia-api/revisions/684b3751bfd3?raw)
