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

# Loomio plugin

> Group decision making with Loomio: groups, discussions, comments, polls, threads, memberships, search, participation reports and group webhooks through the User API, plus user and membership admin through the Server API on self-hosted installs.

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

Create an API key by signing in at loomio.com and opening the API access page at [https://www.loomio.com/profile/api\_access](https://www.loomio.com/profile/api_access). The page also lists your groups with their numeric ids, which every group-scoped call needs.

* **The key is you.** The key acts as its full user account, with that account's permissions and visibility. Loomio recommends a dedicated bot account for integrations. The key rotates when the account's password changes.
* **Self-hosted installs.** Loomio is open source. Set the account's `base_url` (or the `baseUrl` option) to your install's https origin, e.g. `https://loomio.example.org`; leave it empty for loomio.com. Requests go to `<origin>/api/user0` (never the legacy `/api/b2` prefix, which renames poll fields).
* **Server API (self-hosted only).** The `server.*` operations call `/api/server0` and authenticate with the install's `SERVER_API_KEY` instead of a user key: list every group, sync memberships and roles, and create, update, deactivate, redact or delete user accounts. They are not available on loomio.com. Use a separate Corsair account for the server key.
* **Header auth only.** Requests authenticate with `Authorization: Bearer <key>`. Query-string keys are rejected.
* **Bad keys answer 403.** A missing or invalid key gets 403 `{"error":"You are not authorized to access this page."}`, and so does a permission denial, even on calls that name a record. Errors are core `ApiError`s with the status and Loomio's message; the sent body (content, email addresses) is stripped.
* **Compound envelopes.** User API responses carry the primary records in an array named after the resource (`groups`, `discussions`, `threads`, `items`, `polls`, `comments`, `memberships`, `chatbots`), related records in sibling arrays (users, topics, groups, poll\_options, outcomes), and `meta: {root, total}`. Single-record calls also return the record under a singular key (`group`, `discussion`, `thread`, `comment`, `poll`, `chatbot`). Pass `compact: true` or `exclude_types` on reads to drop bulky related records. Thread titles are not on the thread record: join the related `discussions` (or `polls`) array on `topicable_id`.
* **Paging.** List calls take `limit` (default 50; capped at 500 for groups, thread items and webhooks; 50 on the Server API) and `offset`, and return `meta.total` plus a derived `next_offset` that disappears on the last page. Search returns up to 20 results and reports return the whole section, without paging.
* **Polls.** A poll without `closing_at` stays a draft with voting disabled. Proposal polls default to the agree, disagree, abstain, and block options when `options` is omitted. Options ride in the related `poll_options` array and the current outcome in `outcomes`, matched by `current_outcome_id`.
* **Who gets emailed.** `recipient_emails`, `recipient_user_ids` and `recipient_audience: 'group'` on discussions and polls notify or invite people, and `memberships.manage` emails every new address; these operations are `destructive`. Deletes of discussions, comments and polls are soft deletes the API cannot undo.
* **Webhooks.** Group admins manage outgoing webhooks (Loomio's `/chatbots` route) with `webhooks.*`. Deliveries are chat-style messages with no signature, so this plugin does not receive them; treat the destination URL as a secret and use the API for current state.
* **Writes are not idempotent.** A retry of a failed create can post twice, so the plugin replays only reads on server errors. Core retries 429s; Loomio sends no rate-limit headers (the hosted service allows about 900 requests per 5 minutes per IP).

**What you get:**

* 47 typed API operations

## Setup

**1. Install**

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

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

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

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

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

## Example API calls

**List the latest discussions in a group**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.loomio.api.discussions.list({ group_id: 12, limit: 20 });
```

**Comment on a discussion**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.loomio.api.comments.create({ discussion_id: 88, body: 'Sounds good to me.' });
```

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

## What's next

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