Apply object grants¶
Save the complete grant changes for one role on one object. Saving changes the actions available to that role on the object.
PUT https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/permissions/objects/{resource_type}/{resource_id}/roles/{role_id}/grants
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 PUT "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/permissions/objects/$RESOURCE_TYPE/$RESOURCE_ID/roles/$ROLE_ID/grants" \
-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 idempotency request ID. |
|
object array |
Yes |
Grant changes to save; 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, the grant changes are saved and a new policy version is returned. Replaying the same request ID with identical content does not apply the changes again.
{"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":2,"statement_count":1,"added_count":1,"removed_count":0,"idempotent_replay":false,"canonical_policy_hash":"sha256:example","validate_only":false,"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 the update. |
|
integer |
Policy version after the update. |
|
integer |
Number of policy statements after the update. |
|
integer |
Number of added statements. |
|
integer |
Number of removed statements. |
|
boolean |
Whether this is an idempotent replay of the same request. |
|
string |
Hash of the policy after saving. |
|
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 |
— |