# View role deletion impact

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

View bindings, inheritance, ownership, grants, and pending changes that still require handling before a role can be deleted. The result is a current snapshot; deletion performs the checks again.

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

## Preparation before calling

First [select the role](list-roles.md#select-a-role) to evaluate, and assess its impact using the current state shown in the list. Prepare a personal access token with the required permission in 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 -G "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/roles/$ROLE_ID/delete-impact" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  --data-urlencode "expected_lifecycle_version=3"
```

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

### Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| workspace_id | string | Yes | Target workspace ID. |
| role_id | string | Yes | Target role ID. |

### Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| expected_lifecycle_version | integer | Yes | Current role lifecycle version. Must be greater than `0`. |

The deletion impact is a snapshot at read time and cannot replace the final deletion check. Submit the latest lifecycle version when deleting the role.

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

## Successful response

On success, returns counts for role bindings, inheritance, ownership, policy grants, and pending operations that could block deletion.

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

```json
{"code":"OK","msg":"OK","data":{"role":{"role_id":"role-001","lifecycle_state":"disabled","lifecycle_version":3},"direct_binding_count":0,"default_role_count":0,"parent_inheritance_count":0,"child_inheritance_count":0,"active_ownership_count":0,"active_policy_grant_count":0,"pending_operation_count":0,"blocked":false}}
```

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

| Field | Type | Description |
| --- | --- | --- |
| code | string | `OK` on success. |
| msg | string | `OK` on success. |
| data.role | object | Summary of the assessed role. |
| data.direct_binding_count | integer | Users directly bound to the role. |
| data.default_role_count | integer | Users that have the role as their default role. |
| data.parent_inheritance_count | integer | Direct parent inheritances of the role. |
| data.child_inheritance_count | integer | Child roles that directly inherit from the role. |
| data.active_ownership_count | integer | Active ownerships held by the role. |
| data.active_policy_grant_count | integer | Active policy grants that still reference the role. |
| data.pending_operation_count | integer | Operations not completed or pending repair. |
| data.blocked | boolean | Whether deletion is currently blocked. |

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

## 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 deletion impact

Before deleting a role, confirm there are no bindings, inheritances, ownerships, grants, or pending changes that still require handling. The result is a snapshot; the API checks again when deletion is performed.
