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

# PostOnce plugin

> Publish and schedule posts with text and media to LinkedIn, X, Threads, Bluesky, Facebook Pages, Instagram, TikTok, YouTube and Pinterest, keep drafts, upload media, read post analytics and manage cross-posting workflows and webhooks.

Use **PostOnce** through Corsair: one client, typed API calls, local DB sync.

Create an API key in the PostOnce dashboard under Preferences, API Keys, and pick its scopes there. The plugin sends it as `Authorization: Bearer <key>`. Posts, drafts and analytics need `accounts:read`, `posts:read` and `posts:write`; `media.*` needs `media:read`/`media:write`, `workflows.*` needs `workflows:read`/`workflows:write`. A key without a scope gets a 403 for those calls.

Things to know:

* **Accounts are the targets.** `accounts.list` returns each connected account's `id`, `status` and `media_requirements`. Pass the ids as `targets[].account_id` in `posts.create`, and only post to accounts whose `status` is `active`. Instagram, TikTok, YouTube and Pinterest need at least one image or video.
* **Now or later.** `posts.create` without `publish_at` publishes right away. With an ISO-8601 `publish_at` it is scheduled, and `posts.cancel` stops it before it runs.
* **Media goes in by URL.** `media[].url` must be an absolute HTTP or HTTPS URL that PostOnce can download when it publishes.
* **Retries do not double-post.** Pass `idempotencyKey` (sent as the `Idempotency-Key` header) to `posts.create`, `drafts.create` or `workflows.create`: a repeat with the same body returns the original. After a 5xx or network error the plugin retries reads only; a write whose reply was lost may already have run, so it is never replayed.
* **Drafts before posts.** `drafts.create` saves text, media and intended accounts without scheduling anything. `drafts.update` needs the draft's current `updated_at` as `expected_updated_at` and returns 409 if it changed since.
* **Uploading media.** `media.createUpload` returns a signed URL and a `media_id`. PUT the file's bytes to the URL, then `media.get` gives the `public_url` to use as `media[].url`.
* **Workflows post on their own.** An active workflow copies every new post from its source account to its targets, so `workflows.create` and `workflows.update` are destructive.
* **Webhooks.** `webhooks.create` registers an HTTPS endpoint for `post.published`, `post.partially_published` and `post.failed`; the reply is the only time its signing secret is shown. This plugin does not receive those events yet.
* **One post, many destinations.** A post's `status` sums up its `targets`; each target carries its own `status`, `platform_post_url` and `error`.
* **Paging.** `posts.list` returns up to `limit` posts (default 20, max 100), newest first. Pass `meta.next_cursor` as `after` for the next page; it is null on the last page.

**What you get:**

* 25 typed API operations
* 2 synced entities (`accounts`, `posts`) for fast `.search()` / `.list()`

## Setup

**1. Install**

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

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

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

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

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

## Example API calls

**List connected social accounts**

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

**Schedule a post to one account**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.postonce.api.posts.create({
	content: 'Launching today',
	targets: [{ account_id: 'ACCOUNT_ID' }],
	publish_at: '2026-12-01T15:00:00Z',
});
```

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

## Query synced data

Synced entities support `tenant.postonce.db.<entity>.search()` and `.list()`: `accounts`, `posts`.

See [Database](https://docs.corsair.dev/plugins/postonce/database.md) for filters and operators.

## What's next

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

> [card] [Database](https://docs.corsair.dev/plugins/postonce/database.md)
>
> Synced entities, search filters, and operators.

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