Skip to main content
The Roles Service provides endpoints for creating, managing, and assigning roles and permissions within organizations. It implements a robust role-based access control (RBAC) system that allows fine-grained control over user permissions.

Authentication

All endpoints require a valid Bearer token in the Authorization header.

Base URL

Endpoints Overview

Role Endpoints

Create Role

Create a new custom role within an organization.
Endpoint: POST /api/roles/create Query Parameters: Request Body:
Requires roles:write permission. System roles (owner, admin, member, guest) cannot be created this way - they are automatically created with each organization.

Update Role

Update an existing custom role.
Endpoint: PUT /api/roles/update Query Parameters: Request Body: All fields are optional - only include fields you want to update:
System roles (owner, admin, member, guest) cannot be updated. Only custom roles created via the API can be modified.

Delete Role

Delete a custom role from an organization.
Endpoint: DELETE /api/roles/remove Query Parameters:
  • System roles cannot be deleted
  • Roles assigned to members cannot be deleted (reassign members first)
  • This action cannot be undone

List Roles

Retrieve all roles for an organization (includes both system roles and custom roles).
Endpoint: GET /api/roles/list_roles Query Parameters:
Returns both system roles (owner, admin, member, guest) and organization-specific custom roles. System roles have is_system_role: true and organization_id: null.

Permission Endpoints

List All Permissions

Retrieve all available permissions in the system.
Endpoint: GET /api/roles/list_permissions
This returns all system-wide permissions. Use these permission IDs when creating or updating roles.

Create Permission

Create a new system-wide permission.
Endpoint: POST /api/roles/permission Request Body:
Permissions follow the resource:action naming convention (e.g., kb:read, agent:execute, *:admin).

Delete Permission

Delete a permission from the system.
Endpoint: DELETE /api/roles/permission Query Parameters:
Deleting a permission will remove it from all roles that have it assigned. This action cannot be undone.

Managing User Roles

To assign or update a user’s role within an organization, use the Users Service endpoints:
  • Update User Role: PUT /api/users/update - Change a user’s role (requires owner permission)
  • List Users: GET /api/users/list - See all users and their roles in an organization
See the Users Service API documentation for details.

Error Responses

Implementation Notes

System Roles

Four system roles are automatically created with each organization: System roles cannot be created, updated, or deleted via the API.

Custom Roles

  • Custom roles are organization-specific
  • Hierarchy levels determine role precedence (0-100)
  • Higher levels generally have more privileges
  • Role names must be unique within an organization
  • Roles assigned to members cannot be deleted

Permission Format

Permissions follow the resource:action pattern:
  • Resources: kb, conversation, agent, tool, organization, users, roles
  • Actions: read, write, delete, admin, execute
  • Wildcards: *:read (read all resources), kb:* (all kb actions), *:* (full access)

Required Permissions

  • Create/Update/Delete Roles: Requires roles:write permission
  • Delete Roles: Requires roles:delete permission
  • View Roles: Requires roles:read permission
  • Manage Permissions: Requires system-level admin access