Set the current user’s default role

PUT https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/iam/me/default-role

Before you call this API

From the current caller’s role list, obtain a selectable directly bound role and default_role_version, saving TARGET_ROLE_ID and DEFAULT_ROLE_VERSION. Prepare Workspace credentials, jq, and this operation’s REQUEST_ID. The target cannot merely be reachable through inheritance.

Request

curl -X PUT "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/iam/me/default-role" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  --data-binary "$(jq -n --arg role "$TARGET_ROLE_ID" --arg request "$REQUEST_ID" --argjson version "$DEFAULT_ROLE_VERSION" '{target_role_id:$role,expected_default_role_version:$version,request_id:$request}')"

Field

Type

Description

target_role_id

string, required

Canonical positive integer role ID; must be an active/ready direct binding selectable by the current user.

expected_default_role_version

integer

Current default role version, at least 0. Omission is 0, not a bypass of concurrency checking.

request_id

string, required

Operation identifier; confirmation with identical content uses the original ID.

Result

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "default_role_id": "7",
    "default_role_version": 3,
    "schema_version": "definition-example",
    "capability_version": "definition-example",
    "audit_event_id": "audit-example",
    "request_id": "default-example",
    "trace_id": "trace-example",
    "idempotent_replay": false
  }
}

Default role, receipt, and audit are saved in one transaction. Same user/Workspace/request_id and identical content can replay; reusing the ID with a changed target/input version conflicts. Reread current role context to confirm the new default. This adds no user binding and changes no other users.

An explicit current candidate still takes precedence over the default. Changing the default role does not automatically override configured SDK/CLI Workspace-role mappings.

No dedicated default-role setter method/command was found in current Go/Python/CLI. Use this page’s HTTP request rather than an invented client method.

Last updated on