---
title: "Assign Role To User"
method: POST
path: "/workspaces/{workspace_id}/roles"
---

# Assign Role To User

`POST /workspaces/{workspace_id}/roles`

Assigns a role to a user in a workspace.

Args:
    payload (UserRole): The payload containing the organization id, user email, and role to assign.
    workspace_id (str): The ID of the workspace.
    request (Request): The FastAPI request object.

Returns:
    bool: True if the role was successfully assigned, False otherwise.

Raises:
    HTTPException: If the user does not have permission to perform this action.
    HTTPException: If there is an error assigning the role to the user.

## Path parameters

- `workspace_id` string, required

## Request body

- UserRole
  - `email` string, required
  - `role` string, nullable
  - `organization_id` string, required

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

## Changes

- **2026-02-13** `72fe88316d15` — 2 info
  - added the optional property `detail/items/ctx` to the response with the `422` status
  - added the optional property `detail/items/input` to the response with the `422` status
- **2025-06-27** `e3e84db47198` — 2 warning, 1 info
  - removed the optional property `detail/items/ctx` from the response with the `422` status
  - removed the optional property `detail/items/input` from the response with the `422` status
  - api tag `Workspaces` removed

[Change history](https://skmtc.dev/agenta-ai/apis/agenta-api/changes/workspaces/:workspace_id/roles/post.md)

---

[API](https://skmtc.dev/agenta-ai/apis/agenta-api.md) · [All operations](https://skmtc.dev/agenta-ai/apis/agenta-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/agenta-ai/agenta-api/revisions/8fcd55a5a656/schema)
