---
title: "Replace a user's roles"
method: PUT
path: "/v1/admin/users/{user_id}/roles"
tags: ["Admin"]
---

# Replace a user's roles

`PUT /v1/admin/users/{user_id}/roles`

## Request

- Base URL: `https://api.naturali.ai`
- URL: `https://api.naturali.ai/v1/admin/users/{user_id}/roles`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://api.naturali.ai/authorize`, token URL `https://api.naturali.ai/token`, scopes: `mcp:access`)

Replaces the platform roles of any user. Needs the `admin` role, and each role that changes needs the caller to hold the role that grants it (today `admin` grants `admin`). Values outside the catalog are rejected with a 400, and a caller cannot remove their own `admin` role.

## Path parameters

- `user_id` string, required

## Request body

- UserRolesUpdate
  - `roles` string[], required: The complete new list; an empty array clears every role.

## Response `200`

The user with the new roles.

- User
  - `id` string, required: Public user ID (user_ prefix).
  - `email` string, email, required
  - `name` string, nullable
  - `email_verified` boolean, required
  - `roles` string[], required: Roles on naturali itself, not on a project. Empty for almost every account; `admin` marks a naturali operator. Changed only through `PUT /v1/admin/users/{user_id}/roles`, by a caller holding the role that grants each one.
  - `usage_alerts` boolean, required: Whether the account is emailed when its model credit, runs or indexed storage reaches 75%, 90% and 100%. On for a new account.
  - `created_at` string, date-time, required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Missing or invalid credentials.
- `403`: The caller does not hold the `admin` role.
- `404`: No such user.

---

[API](https://skmtc.dev/naturali/apis/naturali-ai-api.md) · [All operations](https://skmtc.dev/naturali/apis/naturali-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/naturali/apis/naturali-ai-api/revisions/e4905b78f422?raw)
