---
title: "Create User Assignment"
method: POST
path: "/rbac/user-assignments"
tags: ["rbac"]
---

# Create User Assignment

`POST /rbac/user-assignments`

## Request

- Base URL: `https://platform.tracecat.com/api`
- URL: `https://platform.tracecat.com/api/rbac/user-assignments`
- Auth: one of:
  - API key in cookie `fastapiusersauth`
  - HTTP bearer

Create a user role assignment.

Assigns a role directly to a user. If workspace_id is None, creates an org-wide
assignment that applies to all workspaces. Each user can have at most
one assignment per workspace (or one org-wide assignment).

Requires: org:rbac:create scope

## Request body

- UserRoleAssignmentCreate: Create schema for a user role assignment.
  - `user_id` string, uuid, required: User ID to assign role to
  - `role_id` string, uuid, required: Role ID to assign to the user
  - `workspace_id` string, uuid, nullable: Workspace ID for workspace-level assignment. If None, creates org-wide assignment.

## Response `201`

Successful Response

- UserRoleAssignmentReadWithDetails: Read schema for a user role assignment with user and role details.
  - `id` string, uuid, required
  - `organization_id` string, uuid, required
  - `user_id` string, uuid, required
  - `workspace_id` string, uuid, nullable
  - `role_id` string, uuid, required
  - `assigned_at` string, date-time, required
  - `assigned_by` string, uuid, nullable
  - `user_email` string, required
  - `role_name` string, required
  - `workspace_name` string, nullable

## Other responses

- `400`: Organization role assigned on a workspace.
- `404`: User, role, or workspace not found.
- `409`: User already has an assignment for this workspace.
- `422`: Validation Error

---

[API](https://skmtc.dev/tracecat/apis/tracecat-api.md) - [All operations](https://skmtc.dev/tracecat/apis/tracecat-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tracecat/apis/tracecat-api/revisions/2efdda25045f?raw)
