Modify¶
POST /api/v1/role/{role_uuid}/modify
Overview¶
Modify the name, optional description, and complete permission set of a workspace custom role.
Before Calling and Usage Steps¶
First read Role Details to save the existing permissions, then submit the complete target keys and the required name. keys replaces the old authorization as a whole; omitting it or passing [] reports RolePermissionFormatInvalid and cannot be used to clear all permissions. Omitting desc keeps it unchanged; an empty string clears it. Built-in roles in management backend applications cannot be modified through this API. When using it for workspace custom roles, first confirm the permission impact on existing members and API Keys. After permission relationships are saved, the permission caches of associated accounts and API Keys are refreshed, and existing role bindings are not removed; if the call fails, new permissions may already have been saved, so query first before retrying. The server deduplicates and expands optional permissions and automatically adds routine.defaultAccess; a successful modification returns only true and does not directly return the final permission list. Query the permissions in Role Details again. For legacy wildcard groups such as workspace/cloudAccount/cloudBilling/rumApp, newly available administrator permissions are not automatically granted because of old wildcard groups; submit the corresponding leaf keys explicitly according to the selectable scope.
Route Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| role_uuid | string | Y | Workspace custom role UUID. Do not replace it with a name or the UUID of a management backend built-in role template. Example: role_exampleHow to obtain or enter: Obtain the target workspace custom role from content.data[].uuid in Role List; you can verify it with Role Details. |
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or enter: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace. |
Request Body Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| keys[*] | string | Single permission key in group.permission format. It must be within the selectable scope of the current custom role. group.* can be expanded according to the allowed scope; explicitly submitting leaf permissions is preferred. Example: anomaly.issueManageHow to obtain or enter: Confirm in Role Management in the console which permissions can currently be selected by custom roles; you can also refer to content.permissions in Role Details of a similar custom role and select specific leaf keys based on business needs. Do not copy permissions exclusive to system roles. |
|
| name | string | Y | Role name, required for both creation and modification, up to 256 characters. Allows null: False Maximum length: 256 Example: 异常协作处理How to obtain or enter: First use Role List to check roles visible in the current workspace, and choose a name that is not already in use. |
| desc | string | Optional description. If omitted during creation, it is an empty string; if omitted during modification, the original value is retained, and passing an empty string clears it. The runtime declares a maximum length of 3000, but the current storage capacity is shorter, so it is recommended to keep it within 256 characters. Allows null: False Allows empty string: True Maximum length: 3000 Example: 允许处理异常追踪问题。How to obtain or enter: Fill it in according to the role's purpose; it is recommended not to exceed 256 characters, consistent with the current storage capacity. |
|
| keys | array | Permission key string array. Required on creation; although modification declares it as optional, at least one valid permission must actually be provided. Updates replace old permissions as a whole; they do not append. Allows null: False Example: ["anomaly.issueManage"]How to obtain or enter: Confirm in Role Management in the console which permissions can currently be selected by custom roles; you can also refer to content.permissions in Role Details of a similar custom role and select specific leaf keys based on business needs. Do not copy permissions exclusive to system roles. |
Additional Parameter Notes¶
If the target role does not exist, the current path may produce a generic internal error instead of reliably returning NotFoundRole; verify the role first through Role List or Role Details. After a call fails, confirm the effective status using Role Details and actual access results.
Request Example¶
curl --request POST 'https://openapi.truewatch.com/api/v1/role/role_example/modify' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"name":"异常协作处理","keys":["anomaly.issueManage"]}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content | boolean | The modification process returns true; read the final permissions through Role Details. |
{
"code": 200,
"content": true,
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling Method |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | A request field is missing, or a field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | The request JSON syntax is invalid | Request JSON format error | Fix the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The JSON top level is not an object | Some JSON file format error | Submit a single JSON object. |
| 406 | ft.RolePermissionFormatInvalid | keys is omitted, empty, contains no valid permissions, or a permission is not in group.permission format | Role permission format error | Submit at least one currently selectable permission key; each entry uses two dot-separated segments. |
| 406 | ft.RolePermissionInvalid | The permission group or sub-permission is not in the current custom role's selectable set | Role permission is invalid | Reselect from the selectable scope in the console or the permission details of a similar custom role. |
| 400 | ft.RoleNameExists | A role with the same name exists in the currently visible workspace scope | Role name {} already exists |
Use a name that is not already in use. |
| 500 | ft.InternalServerError | Saving, permission refresh, or other internal processing failed | Internal error | First query Role Details to confirm the saved name and permissions, then decide whether to retry; if the failure persists, provide the traceId. |
| 400 | ft.InvalidAction | Attempt to modify a built-in role of a management backend application | Invalid operation | Maintain the built-in role in the corresponding management backend, or select a workspace custom role. |