# Get user role bindings

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

View the roles and default role of a specified user in the current workspace. Use this information when adjusting role assignments.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/users/{user_id}/role-bindings
```

## Preparation before calling

First [select the user](list-users.md#select-a-user).

Prepare a [personal access token](../../../../../guides/genesis/api-keys.md#manage-api-keys) and [target workspace ID](../../../../../guides/ai-studio/resource-center/workspace.md#copy-a-workspace-id) with access to the target workspace.

## Request parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Input example

```bash
curl -X GET "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/users/$USER_ID/role-bindings" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameter description

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Target workspace ID. |
| `user_id` | string | Yes | ID of the user whose role bindings you want to view. |

:::::
::::::
:::::::
## Successful response

On success, returns the user's direct role bindings, default role, and concurrency-control versions. When the user has no direct role bindings, the service can omit the role and default-role fields. Read the current versions again before updating bindings.

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "user_id": "user-001",
    "binding_version": "binding-v3",
    "request_id": "req-001",
    "trace_id": "trace-001"
  }
}
```

:::::
:::::{tab-item} Field details

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.user_id` | string | Target user ID. |
| `data.roles` | object (array) | Roles directly bound to the user, including their lifecycle, deployment, and optional states; returned when direct bindings exist. |
| `data.default_role_id` | string | Current default role ID; returned when a default role exists. |
| `data.default_role_version` | integer | Current default role version; returned when a default role exists. |
| `data.binding_version` | string | Current role-binding version marker. |
| `data.request_id` | string | Request correlation ID. |
| `data.trace_id` | string | Trace ID. |

:::::
::::::
:::::::

## Error response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

:::::
:::::{tab-item} Field details

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code. |
| `msg` | string | Error message. |
| `data` | null | — |

:::::
::::::
:::::::

## Next steps

### Confirm current role bindings

Before updating a user's role bindings, confirm the user's current roles and default role, and use the binding state read on this page to prepare the change.
