Validate object grants¶
Check whether grant changes for one role on one object can be saved without modifying existing grants. Apply the changes separately after validation succeeds.
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/permissions/objects/{resource_type}/{resource_id}/roles/{role_id}/grants:validate
Preparation before calling¶
Select the object and role to grant, then view the object permission view to confirm the current grant state. Next, view the permission schema to select supported actions and grant scopes.
Prepare a personal access token with the required permissions for the target workspace and the target workspace ID.
Request parameters¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/permissions/objects/$RESOURCE_TYPE/$RESOURCE_ID/roles/$ROLE_ID/grants:validate" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"schema_version": "current-schema-version",
"expected_policy_version": 1,
"expected_role_lifecycle_version": 1,
"request_id": "req-001",
"changes": [{"remove": false, "action_id": "workflow.read"}]
}'
Path parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Target workspace ID. |
|
string |
Yes |
Resource type of the target object. |
|
string |
Yes |
Resource ID of the target object. |
|
string |
Yes |
Role ID receiving the grant changes. |
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Permission schema version used by this change. |
|
integer |
No |
Policy version used for concurrency checks; cannot be less than 0. |
|
integer |
Yes |
Current role lifecycle version; must be greater than 0. |
|
string |
Yes |
Caller-generated request ID. |
|
object array |
Yes |
Grant changes to validate; must contain at least one item. |
|
boolean |
No |
|
|
string |
Yes |
Action ID in the permission schema. |
|
string |
No |
Hash of the condition expression. |
Successful response¶
On success, returns a preview of the grant changes. validate_only is true; the policy is not saved.
{"code":"OK","msg":"OK","data":{"workspace_id":"workspace-001","resource_type":"workflow","resource_id":"workflow-001","target_role_id":"role-001","previous_policy_version":1,"policy_version":1,"statement_count":1,"added_count":1,"removed_count":0,"idempotent_replay":false,"canonical_policy_hash":"sha256:example","validate_only":true,"request_id":"req-001","trace_id":"trace-001"}}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Target workspace ID. |
|
string |
Target resource type. |
|
string |
Target resource ID. |
|
string |
Role ID receiving the grant changes. |
|
integer |
Policy version before validation. |
|
integer |
Policy version used by validation; validation does not increment it. |
|
integer |
Number of policy statements after the change. |
|
integer |
Number of statements that would be added. |
|
integer |
Number of statements that would be removed. |
|
string |
Hash of the normalized policy. |
|
boolean |
Always |
|
string |
Request correlation ID. |
|
string |
Trace ID. |
Error response¶
{"code":"ErrParamInvalid","msg":"Invalid request parameters","data":null}
Field |
Type |
Description |
|---|---|---|
|
string |
Error code. |
|
string |
Error message. |
|
null |
— |