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

# Ghost plugin

> Publish with Ghost: posts, pages, tags, members, newsletters, tiers, offers, staff, uploads, themes and webhooks, plus the read-only Content API (82 operations).

Use **Ghost** through Corsair: one client, typed API calls, and incoming webhooks.

In Ghost Admin, open Settings > Integrations > Add custom integration. Connect its **Admin API key** (`<id>:<secret>`) with the site URL; add its **Content API key** as well to use the `content.*` operations. Things to know before you write:

* **Plans.** Self-hosted Ghost has the whole API. On Ghost(Pro), custom integrations come with the Publisher plan and up, not Starter; the Content API works on every plan.
* **Bodies.** Pass the fields of one object (`title`, `html`, `status`...); the plugin sends them in Ghost's `{ "posts": [ ... ] }` format. Ghost stores content as Lexical: send `html` with `source: "html"` to have Ghost convert it.
* **Edits** need the `updated_at` you last read: a stale value answers 409, so two edits never overwrite each other.
* **Publishing and email.** `status: "published"` puts a post on the live site. Updating a post to published with the `newsletter` query value emails it to members, which can't be taken back. Both are marked `destructive`.
* **Staff.** An integration key can list users and roles and send invites; editing or deleting a staff user needs a staff access token of an Administrator.
* **Webhooks.** Ghost signs each delivery with HMAC-SHA256 of the raw body plus a timestamp, in `X-Ghost-Signature: sha256=<hex>, t=<ms>`, using the webhook's secret. The plugin checks it before handling post, page, tag, member and site events. Ghost 6.45 and later name the event in the body; on older releases add `?event=<name>` (for example `?event=post.published`) to the webhook's target URL so the plugin can route it. The signature does not cover that query value, so on older releases a delivery captured in its five-minute window could be resent under another event name that takes the same record (for example `post.added` as `post.deleted`). Upgrade to 6.45+ where you can; otherwise check the record against Ghost before acting on an event where the type matters.

**What you get:**

* 82 typed API operations
* 29 incoming webhook event types

## Setup

**1. Install**

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

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

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

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

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

## Example API calls

**List posts**

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

**Create a draft from HTML**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.ghost.api.posts.create({
	title: 'Release notes',
	html: '<p>What changed this week.</p>',
	source: 'html',
	status: 'draft',
});
```

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

## Webhooks

This plugin registers **29** webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use `webhookHooks` on the plugin factory.

See [Webhooks](https://docs.corsair.dev/plugins/ghost/webhooks.md) for every event path and payload shape, and [Webhooks concept](https://docs.corsair.dev/concepts/webhooks.md) for routing.

## What's next

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

> [card] [Webhooks](https://docs.corsair.dev/plugins/ghost/webhooks.md)
>
> Event paths, payloads, and `webhookHooks` examples.

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