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

# Moneybird plugin

> Accounting with Moneybird: administrations, contacts and contact people, sales invoices (create, send, payments, reminders, PDFs and UBL), estimates, recurring invoices and subscriptions, external sales invoices, documents (purchase invoices, receipts, journal entries), financial accounts, mutations and statements, ledger accounts, tax rates, assets, products, projects, time entries, task lists, reports and exports, webhooks and more (298 operations).

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

The account stores two things: the Moneybird bearer token (a personal API
token, or an OAuth access token) and the administration id the token acts
on. Requests authenticate with `Authorization: Bearer` and every path
except `administrations.list` carries the administration id, so read the
id from `administrations.list` first. Any call can pass its own
`administration_id` to act on another administration the token reaches.

* **Bodies are wrapped the way Moneybird documents them:** a contact goes
  in `contact: {...}`, an invoice in `sales_invoice: {...}`, a send in
  `sales_invoice_sending: {...}`. Ids are digit strings (numbers are
  accepted too).
* **Lists are paginated in a Link response header** the client cannot
  return, so paginated lists take `page` and `per_page` (up to 100; the
  plugin sends 100 when it is left out, since Moneybird's own default differs
  per route) and return `{ items, next_page }`, with `next_page` set while a
  page comes back full. `contacts.listDuplicates` takes no page size, so
  its `next_page` is set while a page has any groups. `listVersions` + `fetchByIds` is Moneybird's
  synchronization API: ids and versions first, then up to 100 records by id.
* **Filtering goes through one string.** List filters are `key:value`
  terms separated by commas (e.g. `state:open|late`, `period:this_year`),
  and a filter you pass replaces the defaults.
* **Sends and money.** `salesInvoices.send`, `salesInvoices.sendReminders`,
  `estimates.send` and `contacts.paymentsMandate.request` email customers;
  `subscriptions.create`, `recurringSalesInvoices.create` and
  `subscriptions.createAndScheduleOneOffSalesInvoice` start invoicing them;
  `contacts.additionalCharges.create` and
  `subscriptions.additionalCharges.create` add a charge to their next invoice;
  `purchaseTransactionBatches.createFromSepaFile` prepares bank transfers.
  All are `destructive`, as is every delete.
* **Downloads** (invoice and estimate PDFs, UBL, attachments, exports)
  answer with a short-lived redirect; the plugin follows it and returns the
  file, saved to Files when Corsair runs with a file store.
* **Scopes.** A token only reaches what its scopes allow (sales\_invoices,
  documents, estimates, bank, time\_entries, settings); each operation's
  description names the scope it needs.
* **Rate limits.** 150 requests per 5 minutes per IP, 50 for `/reports/`.
  Core retries a 429 three times; a 5xx is retried for reads only.
* **Test safely** in a free sandbox administration
  (moneybird.com/administrations/sandboxes/new): full features, watermarked
  invoices.
* Not wrapped: four routes Moneybird marks deprecated (the old
  `register_payment` routes and `DELETE purchase_transactions/{id}/delete`;
  use the `*.payments.create` operations and `purchaseTransactions.delete`), and the
  `events.list` cursor, which only comes in a Link header.

**What you get:**

* 298 typed API operations

## Setup

**1. Install**

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

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

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

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

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

## Example API calls

**List administrations the token can access**

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

**Create a contact**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.moneybird.api.contacts.create({
	contact: {
		company_name: 'Beachy BV',
		firstname: 'Jana',
		lastname: 'Berger',
		country: 'NL',
		send_invoices_to_email: 'billing@example.com',
	},
});
```

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

## What's next

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