> ## 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.

# Superchat plugin

> Multi-channel messaging from Superchat - manage contacts and contact lists, read conversations and their messages, and send text messages on WhatsApp, SMS, Instagram, Messenger, Telegram or email.

Use **Superchat** through Corsair: one client, typed API calls.

Create an API token in Superchat under Settings, then API. You have to be an administrator to see it. Pass it as the plugin's `key` option or store it on the account; the plugin sends it as the `X-API-KEY` header.

Things to know before you write:

* **The API path carries `v1.0`, not `v1`.** A request to `/v1/contacts` answers 405 Method Not Allowed, which reads like a routing bug rather than a wrong path. The plugin uses `v1.0`, as Superchat's own examples do.
* **A missing key is 401 and a wrong key is 403.** The 403 does not mean a scope is missing, so the plugin treats both as an auth failure.
* **Sending reaches a real person.** `messages.send` delivers on WhatsApp, SMS, Instagram, Messenger, Telegram or email, depending on the `from` channel and the recipient's handle. The content has to suit that channel: a channel that only accepts templates will reject a plain text body.
* **One recipient per message.** The spec caps `to` at one entry, and the schema enforces it.
* **A contact needs a handle.** A handle is the email address or phone number that identifies a contact on a channel, and at least one is required. Creating a contact with none would leave Superchat nothing to reach them on.
* **The contact update route requires three fields.** `contacts.update` is a PATCH, but it lists `first_name`, `last_name` and `gender` as required, so a caller changing one sends the other two back. Their values may be null; the keys may not be absent.
* **Snoozing needs two fields.** Set `status: 'snoozed'` together with a `snoozed_until` time, or leave snoozing alone. The schema rejects the mismatch.
* **Paging is by cursor.** `after` takes the last id of the previous page and `before` reads backwards. Only one may be set, and `limit` is 1 to 100, defaulting to 50.
* **Rate limits.** Each workspace gets 2500 requests per 5-minute window, shared across its API keys, and a trial workspace is capped at 10000 calls for its whole lifetime. Both answer 429, and the plugin retries three times with backoff.

**What you get:**

* 22 typed API operations

## Setup

**1. Install**

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

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

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

```bash bun theme={null}
bun add corsair @corsair-dev/superchat 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 { superchat } from '@corsair-dev/superchat';

export const corsair = createCorsair({
	plugins: [
		superchat(),
	],
	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)
>
> Store the Superchat API key before the first call: `pnpm corsair setup --plugin=superchat --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> superchat()
> ```
>
> 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: 'superchat',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Read the messages in a conversation**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.superchat.api.conversations.messages({ id: 'cv_1aBMS9FKwvSDjljRJI1aZ' });
```

**Send a text message to one recipient**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.superchat.api.messages.send({
	to: [{ identifier: 'jane@example.com' }],
	from: { channel_id: 'mc_1aBMS9FKwvSDjljRJI1aZ', name: 'Acme Support' },
	content: { type: 'text', body: 'Hello from Corsair' },
});
```

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

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/superchat/api.md)
>
> Every `superchat.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.