# View the role inheritance graph

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

View the complete role relationships reachable from a specified role to identify indirect inheritance and potential cycles.

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

## Preparation before calling

First [select the role](list-roles.md#select-a-role). 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/$ROLE_ID/inheritance-graph" \
  -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. |
| role_id | string | Yes | Target role ID. |

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

## Successful response

On success, returns the role inheritance graph reachable from the target role and the current role graph version.

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

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "root_role_id": "role-001",
    "edges": [],
    "role_graph_version": "graph-v1"
  }
}
```

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

| Field | Type | Description |
| --- | --- | --- |
| code | string | `OK` on success. |
| msg | string | `OK` on success. |
| data.root_role_id | string | Root role ID of the inheritance graph. |
| data.edges | object[] | Reachable role inheritance edges. |
| data.role_graph_version | string | Current role graph version. |

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

## 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 the inheritance graph

Before adding an inheritance relationship, view the complete role relationship graph and confirm that the new relationship does not create a cycle.
