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

# Overview

> Manage Enginemailer subscribers, categories and custom fields, build and send email campaigns, and read subscriber activity through Enginemailer's N8N API.

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

**API key.** Copy a key from the Enginemailer portal under your user profile (Manage API keys). The plugin sends it in the `APIKey` header. The same key works for the REST API (`subscribers`, `campaigns`) and the N8N API (`n8n`).

**Things to know:**

* **Paid plans.** Free accounts get "Free account is not eligible to use API!" from several calls, and the campaign API is for paid accounts only. Free accounts can insert 50 subscribers a day; paid accounts 10,000.
* **Errors.** The REST API answers HTTP 200 even when a call fails and puts the result in `Result.StatusCode`. The plugin throws when that code is not 2xx, with Enginemailer's message ("API Key Not Found!", "Email Existed", "Campaign Not Found").
* **Subcategories and custom fields.** Subscriber calls take subcategory ids from `subscribers.getSubcategories` and custom fields as `{ customfield_key, customfield_value }` pairs keyed by `subscribers.getCustomFields`. Dates are `dd MMM yyyy`, checkbox values are joined with `|`, phone numbers carry the country code.
* **Batch updates.** `subscribers.batchUpdateSubscribers` takes up to 5,000 subscribers and returns a job `ID`; pass it to `subscribers.batchUpdateStatus` until the status is `Completed`.
* **Campaigns.** An account holds at most 200 campaigns. `campaigns.listCampaigns` lists undelivered campaigns only. `campaigns.assignRecipientList` assigns everyone (`FilterBy: 1`) or the subscribers in a set of subcategories (`FilterBy: 2` with `data`). `campaigns.sendCampaign` mails the whole list at once and cannot be undone.
* **N8N polling.** `n8n.newSubscribers`, `n8n.unsubscribedSubscribers` and the other subscriber feeds return up to 50 records (`limit`) changed since `lastpollingdate` (`yyyy-MM-dd HH:mm:ss`, UTC). A filter set to `All` is left out of the request.
* **N8N lookups.** In live tests on a free account, `n8n.findSubscriber`, `n8n.tagSubscriber`, `n8n.untagSubscriber`, `n8n.deactivateSubscriber` and `n8n.deleteN8nSubscriber` answered "Email not exists." for subscribers the REST API returned, even ones `n8n.addOrUpdateSubscriber` had just created. The `subscribers` operations worked for the same addresses.
* **Transactional email.** `n8n.sendEmail` sends one email right away, either `html` with a `subject` or a `template_id`. `substitution_tags` is a list of `{ Key, Value }` pairs and `cc_emails` takes up to 10 addresses.
* **No local sync.** Data is read from Enginemailer on each call; nothing is stored in the Corsair database.

**What you get:**

* 38 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/enginemailer
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/enginemailer
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/enginemailer
```

```bash bun theme={null}
bun add corsair @corsair-dev/enginemailer
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { enginemailer } from '@corsair-dev/enginemailer';

export const corsair = createCorsair({
	plugins: [
		enginemailer(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

Multi-tenancy is the default — 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}
> enginemailer()
> ```
>
> 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: 'enginemailer',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Look up a subscriber**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.enginemailer.api.subscribers.get({ email: 'ada@example.com' });
```

**Add a subscriber**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.enginemailer.api.subscribers.insert({
	email: 'ada@example.com',
	subcategories: [12],
	customfields: [{ customfield_key: 'first_name', customfield_value: 'Ada' }],
	sourcetype: 'Website sign-up',
});
```

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

## What's next

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