> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloak.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Permissions

> All 31 permission names you can declare or check, their wire codes, and the runtime helpers.

Permissions are referenced by name throughout the SDK. You declare them in [`requiredPermissions`](https://docs.cloak.chat/api-reference/client#constructor-options), check them with [`can()`](https://docs.cloak.chat/api-reference/client#can), and read them from a [`PermissionSet`](#permissionset). The names below are the exact strings to use.

There are **43 permissions, codes 0 through 42**. Names are what you write; the integer codes are the wire contract, and they matter only if you decode a raw grant yourself.

For how declaring and granting work together, see the [Permissions concept](https://docs.cloak.chat/concepts/permissions.md).

```ts theme={null}
const client = new Client({
  token: process.env.CLOAK_TOKEN!,
  requiredPermissions: ['view_text', 'message_send', 'reaction_add'],
});
```

## Administrator

| Name | Code | Controls |
| - | - | - |
| `administrator` | 0 | Grants every permission. |

If your bot holds `administrator` in a server, [`can()`](https://docs.cloak.chat/api-reference/client#can) returns `true` for every other permission there. Ask for it only when your bot genuinely needs full control.

> [!NOTE]
>
> The expansion happens in `can()` only. `administrator` stays a distinct bit in a decoded [`PermissionSet`](#permissionset), so a set where only `administrator` is `true` still has every other boolean `false`. Read it through `can()`, not by inspecting the booleans directly.

## Server management

| Name | Code | Controls |
| - | - | - |
| `manage_channels` | 3 | Create, edit, and delete channels. |
| `view_audit` | 4 | View the audit log. |
| `view_insights` | 5 | View server insights. |
| `manage_server` | 6 | Change server settings, and manage webhooks. |
| `invite_creation` | 7 | Create invites to the server. |
| `emoji_gif_manage` | 10 | Manage the server's emoji and GIFs. |
| `event_invite` | 29 | Invite members to calendar events. |

> [!TIP]
>
> Most bots should not hold `manage_server`. It is only needed to mint or rotate webhooks. If your bot posts webhook embeds, have a human create the webhook in the Cloak app and pass its url in an environment variable instead. See [Webhook embeds](https://docs.cloak.chat/guides/webhook-embeds.md).

## Viewing

| Name | Code | Controls |
| - | - | - |
| `view_text` | 1 | View text channels. Required to receive their messages. |
| `view_voice` | 2 | View voice channels. Joining one is gated separately, see the note below. |
| `message_read_history` | 20 | Read past messages in a channel. |
| `member_list` | 32 | View the member list. |

> [!NOTE]
>
> `view_text` is what puts a text channel on your bot's [firehose](https://docs.cloak.chat/concepts/message-delivery.md). Without it in a given channel, your bot does not receive that channel's messages at all.

> [!NOTE]
>
> `view_voice` does not gate joining a voice channel. The backend's channel-level view check for a voice join runs on a ladder whose server baseline column is `view_text`, so a voice bot declares `view_text` alongside `voice_connect`. See [Joining voice](https://docs.cloak.chat/voice/joining.md#permissions).

## Messaging

| Name | Code | Controls |
| - | - | - |
| `message_send` | 14 | Send messages. Also gates creating a forum post and sending inside one, resolved against the forum channel. |
| `message_manage` | 15 | Manage other members' messages, such as deleting them. Also gates moderating other members' forum posts. |
| `embed_link` | 16 | Post links that render as unfurled previews. Current backends also enforce it for [`sendCard()`](https://docs.cloak.chat/api-reference/client#sendcard). |
| `upload_file` | 17 | Attach files. |
| `reaction_add` | 18 | Add reactions to messages. |
| `mention_roles` | 19 | Mention roles. |
| `commands` | 21 | Use commands. |
| `send_tts` | 33 | Send text-to-speech messages. |
| `send_voice_message` | 34 | Send voice memos. |

## Threads

| Name | Code | Controls |
| - | - | - |
| `create_public_thread` | 39 | Create public threads. |
| `create_private_thread` | 40 | Create private threads. |
| `send_in_thread` | 41 | Send messages inside threads. |
| `manage_threads` | 42 | Archive, lock, rename, and delete any thread, and see private threads uninvited. |

New in SDK 0.3.0, and what [`createThread()`](https://docs.cloak.chat/api-reference/client#createthread) and thread sends gate on. See [Threads](https://docs.cloak.chat/guides/threads.md).

Forums have no equivalent names. Creating a post and sending inside one is `message_send` on the forum channel, and moderating other members' posts is `message_manage`. See [Forums](https://docs.cloak.chat/guides/forums.md).

## Operations

| Name | Code | Controls |
| - | - | - |
| `operations_view` | 35 | View the operations space. |
| `operations_staff_content` | 36 | See staff-only operations content. |
| `operations_manage` | 37 | Manage operations settings and tickets. |
| `operations_protected_identity` | 38 | See protected reporter identities. |

## Members

| Name | Code | Controls |
| - | - | - |
| `nickname_change` | 8 | Change the bot's own nickname. |
| `nickname_manage` | 9 | Change other members' nicknames. |
| `member_kick` | 11 | Remove members from the server. |
| `member_ban` | 12 | Ban members from the server. |
| `member_timeout` | 13 | Time members out. |

## Voice

| Name | Code | Controls |
| - | - | - |
| `voice_connect` | 22 | Connect to voice channels. |
| `voice_speak` | 23 | Speak in voice channels. |
| `voice_video` | 24 | Share video in voice channels. Not available to bots, see below. |
| `voice_activity` | 25 | Use voice activity detection. |
| `members_mute` | 26 | Mute members in voice. |
| `members_deafen` | 27 | Deafen members in voice. |
| `members_move` | 28 | Move members between voice channels. |
| `voice_listen` | 30 | Receive other members' voice media. |
| `soundboard_use` | 31 | Play soundboard sounds. |

> [!WARNING]
>
> **`voice_listen` is the permission that decides whether your bot can hear anything.** `voice_connect` does not imply it.
>
> Without it, your bot joins voice and publishes audio normally, the SFU sends it nothing, and it is never given a key that could decrypt anyone. [`joinVoice()`](https://docs.cloak.chat/api-reference/client#joinvoice) deliberately succeeds without it, because publishing while deaf is the normal configuration for a music or announcement bot. The failure mode for a bot that was supposed to listen is total silence with no error anywhere. See [Voice keys](https://docs.cloak.chat/voice/keys.md).

> [!NOTE]
>
> A bot holding `voice_video` still cannot publish camera or screenshare. A bot session's media credential is minted microphone-only, so video is denied at the credential rather than by the SDK, and peer-to-peer video is deleted from the platform. There is no video path to enable.

## Using names in code

Every name above is a value of the `PermissionName` type.

```ts theme={null}
import type { PermissionName } from '@cloak-software/bot-sdk';

const needed: PermissionName[] = ['view_text', 'message_send'];
```

> [!TIP]
>
> Ask only for the permissions your bot actually uses. A smaller request is easier for a server admin to approve, and it keeps the bot's footprint honest.

### PermissionName

```ts theme={null}
type PermissionName = 'administrator' | 'view_text' | /* ...41 more... */ | 'manage_threads';
```

A union of all 43 names, so you get autocomplete and compile-time checking.

### PERMISSION\_CODES

```ts theme={null}
const PERMISSION_CODES: Record<PermissionName, number>
```

Maps each name to its wire code, `0` through `42`.

```ts theme={null}
import { PERMISSION_CODES } from '@cloak-software/bot-sdk';

PERMISSION_CODES.message_send; // 14
```

### PERMISSION\_NAMES

```ts theme={null}
const PERMISSION_NAMES: PermissionName[]
```

Every name, indexed **by wire code**: `PERMISSION_NAMES[14]` is `'message_send'`. That holds because the code map is dense with no gaps.

### PermissionSet

```ts theme={null}
type PermissionSet = { effectiveRank: number } & Record<PermissionName, boolean>;
```

The resolved capability set for one server: 43 named booleans plus a numeric rank. You get one from [`permissions(serverId)`](https://docs.cloak.chat/api-reference/client#permissions), and the same shape is spread into the [`permissionsUpdate`](https://docs.cloak.chat/api-reference/events#permissionsupdate) payload.

**effectiveRank** `number`

The bot's effective rank in the server. Moderation actions compare ranks: your bot cannot kick, ban, or time out a member whose rank is not below its own.

**\[permission]** `boolean`

One boolean per permission name. `true` means the bot holds it in this server.

```ts theme={null}
client.on('permissionsUpdate', ({ serverId, effectiveRank, ...perms }) => {
  console.log(`send in ${serverId}: ${perms.message_send}, rank ${effectiveRank}`);
});
```

### decodePermArray

```ts theme={null}
decodePermArray(permArray: unknown[], effectiveRank: number): PermissionSet
```

Decodes a raw code-indexed boolean array plus a rank into a named `PermissionSet`. Missing or falsy entries decode to `false`. You need this only when reading a grant off a [raw frame](https://docs.cloak.chat/guides/raw-frames.md); the SDK already decodes the ones it delivers.

```ts theme={null}
import { decodePermArray } from '@cloak-software/bot-sdk';

const set = decodePermArray(rawBooleans, rank);
if (set.message_send) { /* ... */ }
```

> [!WARNING]
>
> `decodePermArray` does **not** expand `administrator`. A set decoded from an administrator grant has `administrator: true` and every other boolean `false`. Only [`can()`](https://docs.cloak.chat/api-reference/client#can) applies the implies-all rule.

## Next

> [card] [Permissions concept](https://docs.cloak.chat/concepts/permissions.md)
>
> How declaring and granting fit together.

> [card] [Errors](https://docs.cloak.chat/api-reference/errors.md)
>
> Reading the permission a denial names.

> [card] [Client](https://docs.cloak.chat/api-reference/client.md)
>
> can(), permissions(), and visibleChannelIds().

> [card] [Voice keys](https://docs.cloak.chat/voice/keys.md)
>
> Why voice\_listen decides what a bot hears.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.