Update user role bindings¶
Updates the specified user’s roles and default roles. Submitting a role assignment replaces the user’s current role binding.
PUT $CLOUDSIGMA_API_BASE/workspaces/{workspace_id}/iam/users/{user_id}/role-bindings
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First select user, then query user role binding to confirm the current binding status. Then Select role to determine new role assignments and default roles.
Prepare personal access token and target workspace ID with corresponding permissions for the target workspace.
Request parameters¶
curl -X PUT "$CLOUDSIGMA_API_BASE/workspaces/$WORKSPACE_ID/iam/users/$USER_ID/role-bindings" \
-H "X-API-Key: $CLOUDSIGMA_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 |
|---|---|---|---|
workspace_id |
string |
Yes |
Target workspace ID. |
user_id |
string |
Yes |
The IAM user ID of the accepted member, taken from the iam_user_id of the same record in the user list. |
Request body
Parameter |
Type |
Required |
Description |
|---|---|---|---|
assigned_role_ids |
array of string |
Yes |
Updated complete list of direct role IDs. |
default_role_id |
string |
No |
Default role ID. |
expected_binding_version |
integer |
No |
Current character binding version. Cannot be less than 0. |
expected_default_role_version |
integer |
No |
Current default character version. Cannot be less than 0. |
request_id |
string |
Yes |
The caller-generated idempotent request ID. |
clear_default_role |
boolean |
No |
Whether to clear the default role. |
This interface completely replaces the user’s direct role binding. When clearing the default role, set clear_default_role to true. When retaining or changing the default role, fill in default_role_id.
When default_role_id is empty and clear_default_role=false, the request will be rejected.
user_id in the path fills in the iam_user_id returned by the user list, and the member must have accepted the invitation. id in the list is the product account UID and cannot replace iam_user_id. Pending invitations cannot be used with this interface.
Successful response¶
{
"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 |
|---|---|---|
code |
string |
OK when successful. |
msg |
string |
OK when successful. |
data.user_id |
string |
The bound user ID has been updated. |
data.assigned_role_ids |
array of string |
Updated direct role ID. |
data.default_role_id |
string |
Updated default role ID. Empty when cleared. |
data.binding_version |
integer |
Updated character binding version. |
data.default_role_version |
integer |
Updated default character version. |
data.audit_event_id |
string |
The audit event ID of this change. |
data.idempotent_replay |
boolean |
Whether it is an idempotent replay of the same request. |
data.request_id |
string |
Request association ID. |
data.trace_id |
string |
Link tracking ID. |
Error response¶
The only common errors are code and msg, and data:null is not returned. data is only possible if there is a core authorization error code, which contains the request ID, tracking ID, and core error code.
{
"code": "ErrParamInvalid",
"msg": "请求参数无效"
}
Field |
Type |
Description |
|---|---|---|
code |
string |
error code. |
msg |
string |
error message. |
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
400 |
|
Invalid request field, workspace, or operation precondition. |
Fix the request parameters and submit again. |
401 |
|
Missing or invalid authentication credentials. |
Check the credential type, expiration, and authentication header. |
403 |
|
The current identity or active role does not have permission for this operation. |
Use an authorized identity or contact an administrator to grant access. |
404 |
|
The target object or required reference was not found. |
Verify the object identifier, workspace, and current status. |
409 |
|
Conflict in resource state, request payload, or concurrent modification. |
Re-read the current state and version, then handle according to the latest result. |
500 |
|
Internal processing failed; write operations may have been partially applied. |
Retain request and trace details, and verify the current state before retrying. |
503 |
|
A business, runtime, or authorization dependency is temporarily unavailable. |
After the dependency recovers, check existing results first instead of blindly repeating writes. |