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

# MailBluster API reference

> API reference for the MailBluster plugin in Corsair: every `mailbluster.api.*` operation with its input and output types, taken from the plugin's Zod schemas.

> [!NOTE]
>
> **New to Corsair?** See [API access](https://docs.corsair.dev/concepts/api.md), [authentication](https://docs.corsair.dev/concepts/auth.md), and [error handling](https://docs.corsair.dev/concepts/error-handling).

## Fields

### create

`fields.create`

Create a custom lead field (label and merge tag).

**Risk:** `write`

```ts theme={null}
await corsair.mailbluster.api.fields.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `fieldLabel` | `string` | Yes | Label shown in MailBluster. |
| `fieldMergeTag` | `string` | Yes | Merge tag used as the key in lead `fields`. |

POST /api/fields with fieldLabel and fieldMergeTag. Paid plans only (403 FeatureLocked on Starter).

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `field` | `object` | Yes | — |

> [accordion] field full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   fieldLabel?: string | null,
>   fieldMergeTag?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***

### delete

`fields.delete`

Delete a custom field and the values every lead holds in it.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.fields.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `fieldId` | `number \| string` | Yes | — |

DELETE /api/fields/\{field\_id}. Leads lose their values for that field. Paid plans only.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `id` | `string \| number` | Yes | — |

***

### list

`fields.list`

List the brand’s custom lead fields.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.fields.list({});
```

**Input:** *empty object*

GET /api/fields. Answers \{fields: \[...]}, not paged.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `fields` | `object[]` | Yes | — |

> [accordion] fields full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   fieldLabel?: string | null,
>   fieldMergeTag?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }[]
> ```

***

### update

`fields.update`

Rename a custom field or change its merge tag.

**Risk:** `write`

```ts theme={null}
await corsair.mailbluster.api.fields.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `fieldLabel` | `string` | Yes | Label shown in MailBluster. |
| `fieldMergeTag` | `string` | Yes | Merge tag used as the key in lead `fields`. |
| `fieldId` | `number \| string` | Yes | — |

PUT /api/fields/\{field\_id}; both fieldLabel and fieldMergeTag are required. Paid plans only.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `field` | `object` | Yes | — |

> [accordion] field full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   fieldLabel?: string | null,
>   fieldMergeTag?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***

## Leads

### create

`leads.create`

Add a lead (subscriber) to the brand. With doubleOptIn it emails the lead an opt-in confirmation; a subscribed lead also receives campaigns and automations.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.leads.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `email` | `string` | Yes | — |
| `subscribed` | `boolean` | Yes | Whether the lead may receive campaigns. Ignored when doubleOptIn is true. |
| `firstName` | `string` | No | — |
| `lastName` | `string` | No | — |
| `fields` | `Record<string, any>` | No | Custom field values keyed by field merge tag (see fields.list). |
| `timezone` | `string` | No | IANA timezone, e.g. America/New\_York. |
| `ipAddress` | `string` | No | Used to look up country, city and timezone. |
| `meta` | `Record<string, any>` | No | Deprecated by MailBluster; use fields. |
| `doubleOptIn` | `boolean` | No | Send the lead an opt-in confirmation email (needs a connected sending provider). |
| `tags` | `string[]` | No | Tag names; missing tags are created. |
| `overrideExisting` | `boolean` | No | If a lead with this email exists, overwrite it instead of failing. |

POST /api/leads. email and subscribed are required. doubleOptIn true sends the lead an opt-in confirmation email (and ignores subscribed); it needs a connected sending provider. Without overrideExisting, an existing email fails. Missing tags are created.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `lead` | `object` | Yes | — |

> [accordion] lead full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   firstName?: string | null,
>   lastName?: string | null,
>   fullName?: string | null,
>   fields?: Record<string, any> | null,
>   email?: string | null,
>   timezone?: string | null,
>   ipAddress?: string | null,
>   subscribed?: boolean | null,
>   optInStatus?: string | null,
>   meta?: Record<string, any> | null,
>   tags?: string[] | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***

### delete

`leads.delete`

Delete a lead. It cannot be restored.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.leads.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `leadHash` | `string` | No | MD5 hash of the lead email, as MailBluster keys leads. |
| `email` | `string` | No | The lead email. The plugin sends its MD5 hash; give this or leadHash. |

DELETE /api/leads/\{lead\_hash}. Answers \{message, leadHash}; the plugin checks the hash matches.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `leadHash` | `string` | Yes | — |

***

### get

`leads.get`

Get one lead by email or by its MD5 email hash.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.leads.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `leadHash` | `string` | No | MD5 hash of the lead email, as MailBluster keys leads. |
| `email` | `string` | No | The lead email. The plugin sends its MD5 hash; give this or leadHash. |

GET /api/leads/\{lead\_hash}, the MD5 hash of the lead's lower-case email. 404 "Lead not found" when there is none.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `number \| string \| null` | No | — |
| `firstName` | `string \| null` | No | — |
| `lastName` | `string \| null` | No | — |
| `fullName` | `string \| null` | No | — |
| `fields` | `Record<string, any> \| null` | No | — |
| `email` | `string \| null` | No | — |
| `timezone` | `string \| null` | No | — |
| `ipAddress` | `string \| null` | No | — |
| `subscribed` | `boolean \| null` | No | — |
| `optInStatus` | `string \| null` | No | — |
| `meta` | `Record<string, any> \| null` | No | — |
| `tags` | `string[] \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

***

### update

`leads.update`

Update a lead found by email or hash: name, email, custom fields, timezone, subscription, and tags to add or remove.

**Risk:** `write`

```ts theme={null}
await corsair.mailbluster.api.leads.update({ email: 'richard@example.com', addTags: ['Customer'], removeTags: ['Trial'] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `leadHash` | `string` | No | MD5 hash of the lead email, as MailBluster keys leads. |
| `email` | `string` | No | The lead email. The plugin sends its MD5 hash; give this or leadHash. |
| `newEmail` | `string` | No | Change the lead's email address. |
| `firstName` | `string` | No | — |
| `lastName` | `string` | No | — |
| `fields` | `Record<string, any>` | No | Custom field values keyed by field merge tag (see fields.list). |
| `timezone` | `string` | No | IANA timezone, e.g. America/New\_York. |
| `ipAddress` | `string` | No | Used to look up country, city and timezone. |
| `meta` | `Record<string, any>` | No | Deprecated by MailBluster; use fields. |
| `subscribed` | `boolean` | No | — |
| `addTags` | `string[]` | No | Tags to attach (created if missing). |
| `removeTags` | `string[]` | No | Tags to detach. Runs after addTags. |

PUT /api/leads/\{lead\_hash}. Every field is optional; newEmail changes the address. addTags runs before removeTags. Answers \{message, lead}.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `lead` | `object` | Yes | — |

> [accordion] lead full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   firstName?: string | null,
>   lastName?: string | null,
>   fullName?: string | null,
>   fields?: Record<string, any> | null,
>   email?: string | null,
>   timezone?: string | null,
>   ipAddress?: string | null,
>   subscribed?: boolean | null,
>   optInStatus?: string | null,
>   meta?: Record<string, any> | null,
>   tags?: string[] | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***

## Orders

### create

`orders.create`

Record an order for a customer email. A new email becomes a lead; with customer.doubleOptIn it gets an opt-in email. Order revenue feeds campaign reports.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.orders.create({ id: 'order-1001', customer: { email: 'richard@example.com' }, currency: 'USD', totalPrice: 6.3, items: [{ id: '101', name: 'Reign HTML Template', price: 3.15, quantity: 2 }] });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | Your own unique order id. |
| `customer` | `object` | Yes | — |
| `currency` | `string` | Yes | ISO currency code, e.g. USD. |
| `totalPrice` | `number` | Yes | — |
| `items` | `object[]` | Yes | — |
| `campaignId` | `number` | No | The campaign this order came from. |

POST /api/orders with your own id, customer (email required), currency, totalPrice and items (id, name, price, quantity). A customer email with no lead becomes a new lead (subscribed unless customer.subscribed is false); products in items are created if missing. Prices come back as decimal strings ("6.30").

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   email: string,
>   firstName?: string,
>   lastName?: string,
>   fields?: Record<string, any>,
>   timezone?: string,
>   ipAddress?: string,
>   subscribed?: boolean,
>   doubleOptIn?: boolean,
>   meta?: Record<string, any>,
>   tags?: string[]
> }
> ```

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   price: number,
>   quantity: number
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `order` | `object` | Yes | — |

> [accordion] order full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   currency?: string | null,
>   totalPrice?: string | number | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   lead?: {
>     id?: number | string | null,
>     firstName?: string | null,
>     lastName?: string | null,
>     fullName?: string | null,
>     fields?: Record<string, any> | null,
>     email?: string | null,
>     timezone?: string | null,
>     ipAddress?: string | null,
>     subscribed?: boolean | null,
>     optInStatus?: string | null,
>     meta?: Record<string, any> | null,
>     tags?: string[] | null,
>     createdAt?: string | null,
>     updatedAt?: string | null
>   } | null,
>   campaign?: {
>     id?: number | string | null,
>     name?: string | null,
>     status?: string | null,
>     recipientName?: string | null
>   } | null,
>   orderItems?: {
>     price?: string | number | null,
>     quantity?: number | null,
>     totalPrice?: string | number | null,
>     product?: {
>       id?: string | number | null,
>       name?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null
>     } | null
>   }[] | null
> }
> ```

***

### delete

`orders.delete`

Delete an order.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.orders.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `orderId` | `string` | Yes | — |

DELETE /api/orders/\{order\_id}. Answers \{message, id}.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `id` | `string \| number` | Yes | — |

***

### get

`orders.get`

Get one order by id.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.orders.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `orderId` | `string` | Yes | — |

GET /api/orders/\{order\_id}.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number \| null` | No | — |
| `currency` | `string \| null` | No | — |
| `totalPrice` | `string \| number \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |
| `lead` | `object \| null` | No | — |
| `campaign` | `object \| null` | No | — |
| `orderItems` | `object[] \| null` | No | — |

> [accordion] lead full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   firstName?: string | null,
>   lastName?: string | null,
>   fullName?: string | null,
>   fields?: Record<string, any> | null,
>   email?: string | null,
>   timezone?: string | null,
>   ipAddress?: string | null,
>   subscribed?: boolean | null,
>   optInStatus?: string | null,
>   meta?: Record<string, any> | null,
>   tags?: string[] | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> } | null
> ```

> [accordion] campaign full type
>
> ```ts theme={null}
> {
>   id?: number | string | null,
>   name?: string | null,
>   status?: string | null,
>   recipientName?: string | null
> } | null
> ```

> [accordion] orderItems full type
>
> ```ts theme={null}
> {
>   price?: string | number | null,
>   quantity?: number | null,
>   totalPrice?: string | number | null,
>   product?: {
>     id?: string | number | null,
>     name?: string | null,
>     createdAt?: string | null,
>     updatedAt?: string | null
>   } | null
> }[] | null
> ```

***

### list

`orders.list`

List orders with customer, campaign and items.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.orders.list({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageNo` | `number` | No | Page number, from 1. |
| `perPage` | `number` | No | Items per page (MailBluster default 10). |

GET /api/orders?pageNo=\&perPage=. Each order has its lead, campaign (or null) and orderItems with product.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `orders` | `object[]` | Yes | — |
| `meta` | `object \| null` | No | — |

> [accordion] orders full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   currency?: string | null,
>   totalPrice?: string | number | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   lead?: {
>     id?: number | string | null,
>     firstName?: string | null,
>     lastName?: string | null,
>     fullName?: string | null,
>     fields?: Record<string, any> | null,
>     email?: string | null,
>     timezone?: string | null,
>     ipAddress?: string | null,
>     subscribed?: boolean | null,
>     optInStatus?: string | null,
>     meta?: Record<string, any> | null,
>     tags?: string[] | null,
>     createdAt?: string | null,
>     updatedAt?: string | null
>   } | null,
>   campaign?: {
>     id?: number | string | null,
>     name?: string | null,
>     status?: string | null,
>     recipientName?: string | null
>   } | null,
>   orderItems?: {
>     price?: string | number | null,
>     quantity?: number | null,
>     totalPrice?: string | number | null,
>     product?: {
>       id?: string | number | null,
>       name?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null
>     } | null
>   }[] | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   total?: number | null,
>   prevPageNo?: number | null,
>   pageNo?: number | null,
>   nextPageNo?: number | null,
>   perPage?: number | null,
>   totalPage?: number | null
> } | null
> ```

***

### update

`orders.update`

Update an order: customer, currency, total, campaign, or replace all items. With customer.doubleOptIn it emails the customer.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.orders.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `orderId` | `string` | Yes | — |
| `customer` | `object` | No | — |
| `currency` | `string` | No | — |
| `totalPrice` | `number` | No | — |
| `items` | `object[]` | No | Replaces every item on the order. |
| `campaignId` | `number` | No | — |

PUT /api/orders/\{order\_id}. items, when given, replaces every item on the order.

> [accordion] customer full type
>
> ```ts theme={null}
> {
>   email?: string,
>   firstName?: string,
>   lastName?: string,
>   fields?: Record<string, any>,
>   timezone?: string,
>   ipAddress?: string,
>   subscribed?: boolean,
>   doubleOptIn?: boolean,
>   meta?: Record<string, any>,
>   tags?: string[]
> }
> ```

> [accordion] items full type
>
> ```ts theme={null}
> {
>   id: string,
>   name: string,
>   price: number,
>   quantity: number
> }[]
> ```

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `order` | `object` | Yes | — |

> [accordion] order full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   currency?: string | null,
>   totalPrice?: string | number | null,
>   createdAt?: string | null,
>   updatedAt?: string | null,
>   lead?: {
>     id?: number | string | null,
>     firstName?: string | null,
>     lastName?: string | null,
>     fullName?: string | null,
>     fields?: Record<string, any> | null,
>     email?: string | null,
>     timezone?: string | null,
>     ipAddress?: string | null,
>     subscribed?: boolean | null,
>     optInStatus?: string | null,
>     meta?: Record<string, any> | null,
>     tags?: string[] | null,
>     createdAt?: string | null,
>     updatedAt?: string | null
>   } | null,
>   campaign?: {
>     id?: number | string | null,
>     name?: string | null,
>     status?: string | null,
>     recipientName?: string | null
>   } | null,
>   orderItems?: {
>     price?: string | number | null,
>     quantity?: number | null,
>     totalPrice?: string | number | null,
>     product?: {
>       id?: string | number | null,
>       name?: string | null,
>       createdAt?: string | null,
>       updatedAt?: string | null
>     } | null
>   }[] | null
> }
> ```

***

## Products

### create

`products.create`

Create a product with your own id.

**Risk:** `write`

```ts theme={null}
await corsair.mailbluster.api.products.create({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string` | Yes | Your own unique product id. |
| `name` | `string` | Yes | — |

POST /api/products with your own id and a name.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `product` | `object` | Yes | — |

> [accordion] product full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   name?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***

### delete

`products.delete`

Delete a product.

**Risk:** `destructive`

```ts theme={null}
await corsair.mailbluster.api.products.delete({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `productId` | `string` | Yes | — |

DELETE /api/products/\{product\_id}. Answers \{message, id}.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `id` | `string \| number` | Yes | — |

***

### get

`products.get`

Get one product by id.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.products.get({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `productId` | `string` | Yes | — |

GET /api/products/\{product\_id}.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number \| null` | No | — |
| `name` | `string \| null` | No | — |
| `createdAt` | `string \| null` | No | — |
| `updatedAt` | `string \| null` | No | — |

***

### list

`products.list`

List products, one page at a time.

**Risk:** `read`

```ts theme={null}
await corsair.mailbluster.api.products.list({ pageNo: 1, perPage: 50 });
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `pageNo` | `number` | No | Page number, from 1. |
| `perPage` | `number` | No | Items per page (MailBluster default 10). |

GET /api/products?pageNo=\&perPage= (defaults 1 and 10). meta has total, pageNo, nextPageNo (null on the last page), perPage and totalPage.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `products` | `object[]` | Yes | — |
| `meta` | `object \| null` | No | — |

> [accordion] products full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   name?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }[]
> ```

> [accordion] meta full type
>
> ```ts theme={null}
> {
>   total?: number | null,
>   prevPageNo?: number | null,
>   pageNo?: number | null,
>   nextPageNo?: number | null,
>   perPage?: number | null,
>   totalPage?: number | null
> } | null
> ```

***

### update

`products.update`

Rename a product.

**Risk:** `write`

```ts theme={null}
await corsair.mailbluster.api.products.update({});
```

**Input**

| Name | Type | Required | Description |
| - | - | - | - |
| `productId` | `string` | Yes | — |
| `name` | `string` | Yes | — |

PUT /api/products/\{product\_id}; only name can change.

**Output**

| Name | Type | Required | Description |
| - | - | - | - |
| `message` | `string \| null` | No | — |
| `product` | `object` | Yes | — |

> [accordion] product full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   name?: string | null,
>   createdAt?: string | null,
>   updatedAt?: string | null
> }
> ```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.