# View role list

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

View roles in the current workspace and whether they can be changed. Use the results to select a role for management, authorization, or inheritance configuration.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/roles
```

## Preparation before calling

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

## 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/roles" \
  -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. |

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

## Successful response

On success, returns a complete list of role summaries in the current workspace, including lifecycle versions and whether policy mutation is allowed.

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

```json
{"code":"OK","msg":"OK","data":{"roles":[{"role_id":"role-001","role_name":"analyst","description":"Data analysis role","lifecycle_state":"active","lifecycle_version":3,"system_role":false,"protected_role":false,"policy_mutation_allowed":true}],"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.roles | object[] | Roles in the current workspace. |
| data.roles[].role_id | string | Role ID. |
| data.roles[].role_name | string | Role name. |
| data.roles[].description | string | Role description. |
| data.roles[].lifecycle_state | string | Role lifecycle state. |
| data.roles[].lifecycle_version | integer | Role lifecycle version. |
| data.roles[].system_role | boolean | Whether this is a system role. |
| data.roles[].protected_role | boolean | Whether this is a protected role. |
| data.roles[].policy_mutation_allowed | boolean | Whether this role's policy can currently be changed. |
| 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

### Select a role

Select the role to manage, authorize, or configure for inheritance. Base later changes on the role's current state from this page to avoid overwriting concurrent changes.
