---
title: "Update User Roles"
method: PUT
path: "/api/v1/auth-management/users/{user_id}/roles"
tags: ["userManagement"]
---

# Update User Roles

`PUT /api/v1/auth-management/users/{user_id}/roles`

Replace a user's roles.

This endpoint allows administrators to replace the roles assigned to a user.

The roles can be scoped to a specific context (e.g., dataset or system).
If a context is provided, the roles will only be replaced within that context.
If no context is provided, all roles (system-level and dataset-level) will be replaced.

To replace roles at the system level, use the "system" context.
To replace roles at the dataset level, use the "dataset:{dataset_id}" context.

## Path parameters

- `user_id` string, required

## Headers

- `Authorization` string, required

## Request body

- UpdateUserRolesRequest — Request model for updating user roles. This model is used when modifying a user's role assignments. It allows for updating the complete list of roles and optionally specifying the context where these roles apply. For example, if the "system" context is used, the roles provided will only replace roles at the system level (ex. dataset roles would remain unchanged). If no context is provided, the role provided in the request will replace all roles for the user.
  - `roles` Role[], required — New list of roles to assign to the user
    - `role_id` string, required — Name of the role (e.g., 'admin', 'editor', 'viewer')
    - `resource` string, nullable — Optional resource type the role applies to (e.g., 'dataset')
    - `resource_instance` string, nullable — Optional resource instance ID the role applies to
  - `roles_context` string, nullable — Context for the roles to update. This can either be 'system' for system-level roles or 'dataset:{dataset_id}' for dataset-level roles.

## Response `200`

The updated user profile with new roles

- UserResponse — Complete user response model including roles. This model extends the base user response to include the user's assigned roles. It is used when the complete user information, including roles, is required.
  - `user_id` string, required — Unique identifier for the user
  - `name` string, required — Display name of the user
  - `email` string, nullable — Email address of the user
  - `picture` string, nullable — URL to the user's profile picture
  - `created_at` string, date-time, required — Timestamp when the user was created
  - `last_login` string, date-time, nullable — Timestamp of the user's last login
  - `roles` Role[], required — List of roles assigned to the user
    - `role_id` string, required — Name of the role (e.g., 'admin', 'editor', 'viewer')
    - `resource` string, nullable — Optional resource type the role applies to (e.g., 'dataset')
    - `resource_instance` string, nullable — Optional resource instance ID the role applies to

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/coactive/apis/api-reference.md) · [All operations](https://skmtc.dev/coactive/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/coactive/api-reference/revisions/1223758be9ba/schema)
