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

# Revolt (Stoat) plugin

> Community chat with Revolt, now branded Stoat - read the account behind a bot or user token, users, direct messages, channels, servers and members, and read, send, edit and delete messages and add reactions.

Use **Revolt (Stoat)** through Corsair: one client, typed API calls.

Revolt has been rebranded **Stoat**, and the published OpenAPI document now points at `api.stoat.chat`; `api.revolt.chat` still answers the same API. Create a bot in the client under user settings, or copy a user session token, then pass it here. Things to know before you call:

* **The header depends on the credential.** A bot token goes in `X-Bot-Token`, a user token in `X-Session-Token`. They are not interchangeable: a bot token in the session header is rejected. Set `credential: 'bot'` (the default) or `'user'`.
* **`Authorization` is not used.** Revolt ignores a bearer header entirely, which is why the plugin writes the token into its own header rather than `TOKEN`.
* **A custom host is supported.** `base_url` targets a self-hosted instance; the default is Stoat's production host.
* **Two error bodies.** Revolt's own errors answer `{ "type": "NotFound", "location": "…" }`, sometimes with the field that was missing (`MissingPermission` adds `permission`). A bad token (401) or a body that cannot be parsed (422) gets the web framework's envelope instead, `{ "error": { "code", "reason", "description" } }`. The plugin reads both. A 429 carries `retry_after` in the body in **milliseconds**, which the rate-limit handler waits.
* **Messages come back with their authors.** With `include_users=true` a message list answers `messages` beside the `users` and `members` those messages reference, so a caller never has to resolve an author id itself. The plugin sends `include_users=true` unless you pass `false`, in which case Revolt answers a bare array and the plugin returns only `messages`.
* **Cursors, not pages.** `before` and `after` are message ids, and they contradict each other, so the schema rejects both at once. `sort` picks the order (`Latest` by default); Stoat ignores it, along with `before` and `after`, when `nearby` is set.
* **A message needs content or an attachment.** An empty post is refused, so the schema requires one of the two.
* **Deletes depend on the channel type.** `messages.delete` removes the message for good. `channels.delete` deletes a server channel with its messages, leaves a group, and only closes a direct message, whose messages stay.

**What you get:**

* 14 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/revolt better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/revolt better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/revolt better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/revolt better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { revolt } from '@corsair-dev/revolt';

export const corsair = createCorsair({
	plugins: [
		revolt(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.
>
> ```ts theme={null}
> revolt()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'revolt',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Read the latest messages in a channel**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.revolt.api.messages.list({ channel_id: '01F8Z1A2B3C4D5E6F7G8H9J0K1', limit: 50 });
```

**Send a message to a channel**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.revolt.api.messages.send({ channel_id: '01F8Z1A2B3C4D5E6F7G8H9J0K1', content: 'Standup in five' });
```

See the full list on the [API](https://docs.corsair.dev/plugins/revolt/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/revolt/api.md)
>
> Every `revolt.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


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