# View data privileges

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

View a role's current data-access privileges, their sources, and editability, to assess or adjust grants.

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

## Preparation before calling

First [select a role](../roles/list-roles.md#select-a-role). Prepare a [personal access token](../../../../../guides/genesis/api-keys.md) that can access 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/data-privileges" -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

Returns the role's current data-privilege view, including direct and inherited privileges, MatrixOne privilege facts, and editability.

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

```json
{"code":"OK","msg":"OK","data":{"target_role_id":"role-001","data_privilege_version":2,"matrixone_fact_version":"fact-v2","items":[],"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.target_role_id` | string | Role ID being viewed. |
| `data.data_privilege_version` | integer | Current data-privilege version; submit it as the expected version when updating. |
| `data.matrixone_fact_version` | string | MatrixOne privilege fact version. |
| `data.items` | object array | Role's data-privilege items. |
| `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":"Invalid request parameters","data":null}
```

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

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

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

## Next steps

### Confirm current data privileges

Before validating or applying data privileges, confirm the role's current data access and prepare changes from the grant state read on this page.
