# Update custom role Update a custom role's name, description, or capabilities. System roles cannot be modified. Requires the `manage_roles` capability. When capabilities are updated, changes take effect immediately for all users assigned to this role. The calling user can only set capabilities they themselves possess (anti-escalation). #### Path Parameters **`organization_id`** string required Organization ID (org_ prefixed string). **`role_id`** string required Role ID (role_ prefixed string). Must be a custom role. #### Request Body **`name`** string optional New role name. Must be unique within the organization. Max 100 characters. **`description`** string optional New description. Max 500 characters. **`capabilities`** array of strings optional Complete list of capabilities. Replaces all existing capabilities. At least one capability required. ## Returns The updated role object with current capabilities and member count. Request ```bash cURL curl -X PATCH "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Marketing Lead", "description": "Updated description", "capabilities": ["view_audit_log", "manage_knowledge_slices", "invite_users"] }' ``` ```python Python SDK from aitronos import Aitronos client = Aitronos(api_key="your-api-key") role = client.organizations.roles.update( organization_id="org_abc123", role_id="role_xyz789", name="Marketing Lead", description="Updated description", capabilities=["view_audit_log", "manage_knowledge_slices", "invite_users"], ) print(role) ``` ```python Python import requests response = requests.patch( "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789", headers={"Authorization": "Bearer YOUR_ACCESS_TOKEN"}, json={ "name": "Marketing Lead", "description": "Updated description", "capabilities": ["view_audit_log", "manage_knowledge_slices", "invite_users"], }, ) print(response.json()) ``` ```javascript JavaScript const response = await fetch( "https://api.aitronos.com/v1/organizations/org_abc123/roles/role_xyz789", { method: "PATCH", headers: { Authorization: "Bearer YOUR_ACCESS_TOKEN", "Content-Type": "application/json", }, body: JSON.stringify({ name: "Marketing Lead", description: "Updated description", capabilities: ["view_audit_log", "manage_knowledge_slices", "invite_users"], }), } ); const role = await response.json(); console.log(role); ``` Response ```json 200 OK { "id": "role_xyz789", "name": "Marketing Lead", "description": "Updated description", "permissions": {}, "is_base_role": false, "is_custom": true, "is_system_role": false, "capabilities": ["view_audit_log", "manage_knowledge_slices", "invite_users"], "member_count": 5, "knowledge_slice_ids": [], "organization_id": "org_abc123", "created_at": "2026-02-20T10:00:00+00:00" } ``` ```json 403 System Role { "success": false, "error": { "code": "SYSTEM_ROLE_IMMUTABLE", "message": "System roles cannot be modified or deleted.", "system_message": "System roles cannot be modified", "type": "client_error", "status": 403, "details": { "role_id": "role_admin123", "role_name": "Admin" }, "trace_id": "abc-123-def", "timestamp": "2026-02-28T12:00:00Z" } } ``` ```json 404 Not Found { "success": false, "error": { "code": "ROLE_NOT_FOUND", "message": "The requested role could not be found.", "system_message": "Role not found", "type": "client_error", "status": 404, "details": { "role_id": "role_nonexistent" }, "trace_id": "abc-123-def", "timestamp": "2026-02-28T12:00:00Z" } } ``` ## Related Resources - [Retrieve role](/docs/api-reference/organizations/roles/retrieve) - [Create custom role](/docs/api-reference/organizations/roles/create-role) - [Delete custom role](/docs/api-reference/organizations/roles/delete-role) - [Role templates](/docs/api-reference/organizations/roles/role-templates) - [List capabilities](/docs/api-reference/organizations/roles/capabilities)