Skip to content

Role Management

Together uses a Discord-compatible role-based permission system. Roles carry a set of permission bitflags and a position in the hierarchy. Higher-position roles outrank lower ones, and non-owner users can only manage roles below their own highest position.


Permission Bitflags

Permissions are stored as a 64-bit integer. Each permission occupies one bit (bits 0-14, maximum value 32767).

BitValueNameDescription
01VIEW_CHANNELView text and voice channels
12SEND_MESSAGESSend messages in text channels
24MANAGE_MESSAGESDelete or pin messages by others
38ATTACH_FILESUpload files and images
416ADD_REACTIONSAdd emoji reactions to messages
532CONNECT_VOICEJoin voice channels
664SPEAKSpeak in voice channels
7128MUTE_MEMBERSTimeout / mute other members
8256KICK_MEMBERSKick members from the server
9512BAN_MEMBERSBan members from the server
101024MANAGE_CHANNELSCreate, edit, and delete channels
112048MANAGE_ROLESCreate, edit, delete, and assign roles
124096(reserved)(unused — reserved for future use)
138192ADMINISTRATORGrants all permissions implicitly
1416384CREATE_INVITESCreate, list, and delete invite links

A role's permissions field is the bitwise OR of all granted bits. For example, a "Moderator" role with MANAGE_MESSAGES, MUTE_MEMBERS, and KICK_MEMBERS would have permissions = 4 | 128 | 256 = 388.


Hierarchy Rules

  1. Server owner bypasses all permission and hierarchy checks. The owner can always manage any role, regardless of position.
  2. ADMINISTRATOR permission grants all other permissions implicitly. Permission checks treat a user with ADMINISTRATOR as having every bit set.
  3. MANAGE_ROLES (bit 11) is required for all role management endpoints (create, update, delete, assign, remove).
  4. Position-based hierarchy: Non-owner users can only manage roles whose position is strictly below their own highest role position. Attempting to create, edit, delete, assign, or remove a role at or above the actor's highest position returns 403 Forbidden.
  5. Cannot grant permissions you don't have: When creating or updating a role, a non-owner/non-administrator user cannot set permission bits they don't already possess.
  6. Cannot remove roles from the server owner: Non-owner users cannot remove roles from the server owner.

Data Model

Role

FieldTypeDescription
idUUIDUnique role identifier
server_idUUIDServer the role belongs to
namestringDisplay name (1-100 characters)
permissionsintegerBitflag value (0-32767)
colorstring?Hex color code (e.g. #FF5733), nullable
positionintegerHierarchy position (higher = more authority)
created_atdatetimeUTC creation timestamp

MemberRoleInfo

Lightweight role summary included in member list responses.

FieldTypeDescription
idUUIDRole identifier
namestringRole display name
colorstring?Hex color code, nullable
positionintegerHierarchy position

Endpoints

All endpoints require a valid Bearer token. The caller must be a member of the server.

Create a Role

POST /servers/:server_id/roles
Authorization: Bearer <token>

Request body:

json
{
  "name": "Moderator",
  "permissions": 388,
  "color": "#3498DB",
  "position": 5
}
FieldTypeRequiredDescription
namestringyes1-100 characters
permissionsintegernoDefaults to 0
colorstringnoHex color code
positionintegernoDefaults to MAX(position) + 1 for the server

Response: 201 Created with the full Role object.

Errors:

ConditionStatusMessage
Missing MANAGE_ROLES permission403You need the Manage Roles permission
Name empty or > 100 characters400Role name must be 1-100 characters
Permissions out of range400Permissions must be between 0 and 32767
Position at or above actor's highest403Cannot create a role at or above your highest role position
Granting permissions actor lacks403Cannot grant permissions you do not have

List Roles

GET /servers/:server_id/roles
Authorization: Bearer <token>

Response: 200 OK with an array of Role objects, ordered by position DESC.

No special permissions are required beyond server membership.


Update a Role

PATCH /servers/:server_id/roles/:role_id
Authorization: Bearer <token>

Request body (all fields optional):

json
{
  "name": "Senior Moderator",
  "permissions": 2436,
  "color": "#E74C3C",
  "position": 8
}
FieldTypeDescription
namestring1-100 characters
permissionsinteger0-32767
colorstringHex color code
positionintegerNew hierarchy position

Only provided fields are updated; omitted fields are left unchanged.

Response: 200 OK with the updated Role object.

Errors:

ConditionStatusMessage
Missing MANAGE_ROLES permission403You need the Manage Roles permission
Role not found404Role not found
Name empty or > 100 characters400Role name must be 1-100 characters
Permissions out of range400Permissions must be between 0 and 32767
Role at or above actor's highest position403Cannot edit a role at or above your highest role position
Moving role to position at or above actor403Cannot move a role to a position at or above your highest role position
Granting permissions actor lacks403Cannot grant permissions you do not have

Delete a Role

DELETE /servers/:server_id/roles/:role_id
Authorization: Bearer <token>

Response: 204 No Content

Deleting a role cascades to member_roles — all assignments of that role are removed.

Errors:

ConditionStatusMessage
Missing MANAGE_ROLES permission403You need the Manage Roles permission
Role not found404Role not found
Role at or above actor's highest position403Cannot delete a role at or above your highest role position

Assign a Role to a Member

PUT /servers/:server_id/members/:user_id/roles/:role_id
Authorization: Bearer <token>

Request body: None.

Response: 204 No Content

If the member already has the role, the request succeeds silently (idempotent via ON CONFLICT DO NOTHING).

Errors:

ConditionStatusMessage
Missing MANAGE_ROLES permission403You need the Manage Roles permission
Role not found404Role not found
Target user not a member404Server not found
Role at or above actor's highest position403Cannot assign a role at or above your highest role position

Remove a Role from a Member

DELETE /servers/:server_id/members/:user_id/roles/:role_id
Authorization: Bearer <token>

Request body: None.

Response: 204 No Content

Errors:

ConditionStatusMessage
Missing MANAGE_ROLES permission403You need the Manage Roles permission
Role not found404Role not found
Target user not a member404Server not found
Target is the server owner (non-owner)403Cannot remove roles from the server owner
Role at or above actor's highest position403Cannot remove a role at or above your highest role position

WebSocket Events

All role events are delivered as DISPATCH messages to all members of the server.

ROLE_CREATE

Broadcast when a new role is created.

json
{
  "id": "uuid",
  "server_id": "uuid",
  "name": "Moderator",
  "permissions": 388,
  "color": "#3498DB",
  "position": 5,
  "created_at": "2026-03-22T12:00:00Z"
}

ROLE_UPDATE

Broadcast when a role is updated.

json
{
  "id": "uuid",
  "server_id": "uuid",
  "name": "Senior Moderator",
  "permissions": 2436,
  "color": "#E74C3C",
  "position": 8,
  "created_at": "2026-03-22T12:00:00Z"
}

ROLE_DELETE

Broadcast when a role is deleted.

json
{
  "server_id": "uuid",
  "role_id": "uuid"
}

MEMBER_ROLE_ADD

Broadcast when a role is assigned to a member.

json
{
  "server_id": "uuid",
  "user_id": "uuid",
  "role_id": "uuid",
  "role_name": "Moderator",
  "role_color": "#3498DB"
}

MEMBER_ROLE_REMOVE

Broadcast when a role is removed from a member.

json
{
  "server_id": "uuid",
  "user_id": "uuid",
  "role_id": "uuid",
  "role_name": "Moderator",
  "role_color": "#3498DB"
}

Channel Permission Overrides

Role permissions define what a user can do across the entire server. Per-channel permission overrides allow fine-tuning on a channel-by-channel basis without changing the role itself.

  • Overrides can target a role or a specific user.
  • Each override carries an allow bitfield (grants permissions) and a deny bitfield (revokes permissions).
  • Role overrides are applied first (merged across all matching roles), then a user-specific override is applied on top with the highest priority.
  • Server owner and ADMINISTRATOR users bypass all channel overrides — they always have full permissions.
  • When no overrides exist for a channel, the user's effective permissions are their server-level role permissions combined with the default member permissions.

For full documentation on override resolution, endpoints, and examples, see channel-permissions.md.


READY Payload

The READY event sent on WebSocket connection includes a server_roles field. This is an object keyed by server ID, where each value is an array of Role objects for that server (ordered by position DESC).

json
{
  "op": "DISPATCH",
  "t": "READY",
  "d": {
    "user": { ... },
    "servers": [ ... ],
    "server_roles": {
      "server-uuid-1": [
        { "id": "role-uuid", "server_id": "server-uuid-1", "name": "Admin", "permissions": 8192, "color": "#E74C3C", "position": 10, "created_at": "..." },
        { "id": "role-uuid", "server_id": "server-uuid-1", "name": "Member", "permissions": 3, "color": null, "position": 1, "created_at": "..." }
      ]
    }
  }
}

Member List

The GET /servers/:id/members endpoint includes a roles array on each member, containing MemberRoleInfo objects (id, name, color, position) for all roles assigned to that member. Roles are ordered by position DESC.


Audit Logging

All role management operations write to the audit log. Logging is non-blocking — if the write fails, the operation is not rolled back.

Actiontarget_typetarget_iddetails
role_createroleRole UUID{ "name": "...", "permissions": 388 }
role_updateroleRole UUID{ "name": "...", "permissions": 2436 }
role_deleteroleRole UUID{ "name": "..." }
member_role_adduserTarget user ID{ "role_id": "...", "role_name": "..." }
member_role_removeuserTarget user ID{ "role_id": "...", "role_name": "..." }