---
title: "Assign roles to a user in an organization"
method: POST
path: "/api/organizations/{id}/users/{userId}/roles"
tags: ["Organizations"]
---

# Assign roles to a user in an organization

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

Assign roles to a user in the specified organization with the provided data.

## Path parameters

- `id` string, required
- `userId` string, required

## Request body

- object
  - `organizationRoleIds` string[] — An array of organization role IDs to assign to the user. User existed roles assignment will be ignored.
  - `organizationRoleNames` string[] — An array of organization role names to assign to the user. User existed roles assignment will be ignored.

## Response `201`

Roles were assigned to the user successfully.

- object
  - `organizationRoleIds` string[], required — An array of organization role IDs that were assigned to the user, deduplicated and resolved from any provided role names.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `422` — The user is not a member of the organization; or at least one of the IDs provided is not valid. For example, the organization ID or organization role ID does not exist; or at least one of the role names provided is not valid. For example, the organization role name does not exist.

---

[API](https://skmtc.net/logto/apis/logto-api-references.md) · [All operations](https://skmtc.net/logto/apis/logto-api-references/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/logto/logto-api-references/versions/a163dc77d842/schema)
