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

# TextIt plugin

> Manage TextIt messaging, contacts, flows, campaigns, tickets, workspace data and outbound resthook subscriptions.

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

TextIt API v2 uses an API token from your TextIt account. List operations return a page with `next`, `previous` and `results`; pass the `cursor` from the next link to request another page.

* Sending messages and broadcasts and starting flows can contact real people. Bulk contact and message actions include permanent deletion.
* Campaign, campaign event and field updates replace the record, so they need the same fields as a create (TextIt answers 400 otherwise). A group used by a campaign can't be deleted until the campaign is archived in TextIt.
* Message actions apply only to incoming messages and take the integer `id` that `messages.list` returns.
* Updating a contact by URN creates it if the URN is unknown. `messageActions.apply` returns `undefined` on complete success or an object `{ failures: [...] }` when some messages could not be updated; access the failed IDs through `result.failures`.
* Upload media with a `Blob` using `media.upload`; its UUID can be used in message attachments.
* Rate-limited requests are retried up to three times, waiting for TextIt's `Retry-After`. Other failures throw Corsair's `ApiError` with the HTTP `status` and TextIt's error body; the default handlers do not replay writes.
* Outbound resthook subscription management is supported; inbound webhook verification is not included.
* The provider's globals create example uses `/global.json`, which currently returns 404; the indexed plural `/globals.json` route is used. Its subscriber ID prose says integer while examples show strings, so both are accepted.

**What you get:**

* 49 typed API operations

## Setup

**1. Install**

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

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

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

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

export const corsair = createCorsair({
	plugins: [
		textit(),
	],
	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 TextIt API key before the first call: `pnpm corsair setup --plugin=textit --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}
> textit()
> ```
>
> 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: 'textit',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**`archives.list`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.textit.api.archives.list({});
```

**`broadcasts.send`**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.textit.api.broadcasts.send({
	contacts: ['09d23a05-47fe-11e4-bfe9-b8f6b119e9ab'],
	text: { eng: 'Hello!' },
});
```

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

## What's next

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