---
title: "Assign a role to a user"
method: POST
path: "/api/users/{userId}/roles"
tags: ["Users"]
---

# Assign a role to a user

`POST /api/users/{userId}/roles`

Assigns the specified role to a user. Admin-only access.

## Path parameters

- `userId` integer, required

## Request body

- AssignRoleRequest — Request for assigning a role to a user.
  - `roleName` string, required — The name of the role to assign.

## Response `200`

Role assigned successfully.

- AssignRoleResponse — Response for assigning a role to a user.
  - `message` string

## Other responses

- `400` — Invalid request or role assignment failed.
- `401` — Unauthorized
- `403` — Forbidden

## Changes

- **2025-11-21** `50eff5014b78` — 1 info
  - endpoint added
- **2025-03-24** `fbc3fe6ecbf1` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/endatix/apis/endatix-platform-rest-api/changes/api/users/:userId/roles/post.md)

---

[API](https://skmtc.dev/endatix/apis/endatix-platform-rest-api.md) · [All operations](https://skmtc.dev/endatix/apis/endatix-platform-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/endatix/endatix-platform-rest-api/revisions/01bd299fd100/schema)
