Update user role bindings¶
Update the roles and default role of a specified user. The submitted role assignment replaces the user’s current role bindings.
PUT https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/iam/users/{user_id}/role-bindings
Preparation before calling¶
First select the user, then view the user’s role bindings to confirm the current binding state. Next, select roles to determine the new role assignment and default role.
Prepare a personal access token and target workspace ID with the required permissions for the target workspace.
Request parameters¶
curl -X PUT "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/iam/users/$USER_ID/role-bindings" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"assigned_role_ids": ["role-001"],
"default_role_id": "role-001",
"expected_binding_version": 0,
"expected_default_role_version": 0,
"request_id": "req-001",
"clear_default_role": false
}'
Path parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Target workspace ID. |
|
string |
Yes |
ID of the user whose role bindings you want to update. |
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string (array) |
Yes |
Complete list of direct role IDs after the update. |
|
string |
No |
Default role ID. |
|
integer |
No |
Current role-binding version; it cannot be less than 0. |
|
integer |
No |
Current default-role version; it cannot be less than 0. |
|
string |
Yes |
Idempotency request ID generated by the caller. |
|
boolean |
No |
Whether to clear the default role. |
This endpoint fully replaces the user’s direct role bindings. The request is rejected when default_role_id is empty and clear_default_role is false. To clear the default role, set clear_default_role to true; to retain or change it, submit the corresponding default_role_id.
Successful response¶
On success, direct role bindings and the default role have been updated in the same transaction, and the response returns the new versions. Replaying the same request ID with identical content does not perform the update again.
{
"code": "OK",
"msg": "OK",
"data": {
"user_id": "user-001",
"assigned_role_ids": ["role-001"],
"default_role_id": "role-001",
"binding_version": 4,
"default_role_version": 3,
"audit_event_id": "audit-001",
"idempotent_replay": false,
"request_id": "req-001",
"trace_id": "trace-001"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
User ID whose bindings were updated. |
|
string (array) |
Updated direct role IDs. |
|
string |
Updated default role ID; empty when cleared. |
|
integer |
Updated role-binding version. |
|
integer |
Updated default-role version. |
|
string |
Audit event ID for this change. |
|
boolean |
Whether this is an idempotent replay of the same request. |
|
string |
Request correlation ID. |
|
string |
Trace ID. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "请求参数无效",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
Error code. |
|
string |
Error message. |
|
null |
— |