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

# Databox plugin

> Business analytics with Databox - create data sources and datasets, push up to 500 records per call, poll ingestion results, read metrics over date ranges with breakdowns, and list dashboards.

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

Create a key at account.databox.com/profile under Password & Security, API key (Admin users only). Things to know before you send:

* **The flow is data source, dataset, ingest.** `dataSources.create` makes the container (only a name is required), `datasets.create` defines columns with `schema` and an optional `primaryKey`, and `datasets.ingestData` pushes records keyed by column ID, at most 500 rows per request. The response returns an `ingestionId`; poll it with `datasets.getIngestion` to see how many records were appended, overwritten or rejected. Databox does not document the ingestion status values, so this plugin does not declare a job; poll until the counts settle.
* **A primary key changes re-ingestion.** With `primaryKey` set, re-ingesting a matching record overwrites it instead of appending a duplicate. Without one, every ingest appends.
* **Deleting a data source cascades.** `dataSources.delete` permanently removes the data source, all of its datasets and all of their records, and cannot be undone.
* **Metrics can trigger a sync.** `metrics.getData` may wait for a due or first sync, up to about two minutes, so the plugin raises that call's timeout; `syncInfo.status` says whether it synced, and `inProgress` or `neverSynced` mean call again shortly. It is rate limited to 30 calls per minute per account.
* **Retry behavior.** A 429 and a 409 `modification_in_progress` both carry `Retry-After` and are retried, because Databox did not process the request; a 409 `modification_failed` is final and is not. Failed writes are never replayed on a 5xx, since they may have been applied. `idempotencyKey` inputs (a UUID) send Databox's `Idempotency-Key` header, which dedupes creation and ingestion calls for 24 hours.
* **Accounts.** Organizations with accounts enabled can pass `accountId` on an operation to act on one account instead of the organization tied to the key.

**What you get:**

* 14 typed API operations

## Setup

**1. Install**

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

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

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

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

export const corsair = createCorsair({
	plugins: [
		databox(),
	],
	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)
>
> No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.
>
> ```ts theme={null}
> databox()
> ```
>
> 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: 'databox',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**List the organization's metrics**

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

**Ingest two transactions**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.databox.api.datasets.ingestData({
	id: 2345678,
	records: [{ transaction_id: 'T-10024', amount: 498, occurred_at: '2026-09-18T09:12:00+00:00' }, { transaction_id: 'T-10025', amount: 59, occurred_at: '2026-09-18T10:03:00+00:00' }],
});
```

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

## What's next

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