# View role inheritance relationships

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

View a specified role's direct parent roles and current inheritance relationships before adding or removing inheritance.

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

## 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" \
  -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 direct inheritance edges for the role and the current role graph version. Submit this version when you update inheritance.

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

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "edges": [{"child_role_id": "role-001", "parent_role_id": "role-parent", "with_grant_option": false, "grant_id": "grant-001"}],
    "role_graph_version": "graph-v1"
  }
}
```

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

| Field | Type | Description |
| --- | --- | --- |
| code | string | `OK` on success. |
| msg | string | `OK` on success. |
| data.edges | object[] | Direct inheritance edges for the role. |
| data.edges[].child_role_id | string | Child role ID. |
| data.edges[].parent_role_id | string | Parent role ID. |
| data.edges[].with_grant_option | boolean | Whether the inheritance grants grant option. |
| data.edges[].grant_id | string | Inheritance grant ID. |
| 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 inheritance relationships

Before adding or removing role inheritance, confirm the current direct parent-role relationships and use the current relationship shown on this page to prepare the change.
