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

# Sender webhooks

> Sender incoming webhooks in Corsair: the event paths to subscribe to, the payload each event carries, and the response data.

The Sender plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/sender/overview.md) for setup context and the exact URL shape).

> [!NOTE]
>
> **New to Corsair?** See [webhooks](https://docs.corsair.dev/concepts/webhooks.md) and [hooks](https://docs.corsair.dev/concepts/hooks.md).

## Webhook map

* `bounces`
  * `created` (`bounces.created`)
* `campaigns`
  * `created` (`campaigns.created`)
* `groups`
  * `created` (`groups.created`)
  * `subscriberAdded` (`groups.subscriberAdded`)
  * `subscriberUnsubscribed` (`groups.subscriberUnsubscribed`)
* `subscribers`
  * `created` (`subscribers.created`)
  * `unsubscribed` (`subscribers.unsubscribed`)
  * `updated` (`subscribers.updated`)

## HTTP handler setup

```ts app/api/webhook/route.ts theme={null}
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    // With multiTenancy, give each tenant its own URL (/api/webhook?tenantId=acme):
    // the query says whose account, secret and hooks handle the delivery.
    const query = Object.fromEntries(new URL(request.url).searchParams);
    // The raw text, not request.json(): signatures are checked over the exact bytes sent.
    const body = await request.text();
    const result = await processWebhook(corsair, headers, body, query);
    if (!result.plugin) {
        return Response.json({ success: false }, { status: 404 });
    }
    // A refusal (bad signature) carries no status and answers 400; a handler
    // that threw comes back with 500, so the sender retries it.
    const status =
        result.response?.success === false ? (result.response.statusCode ?? 400) : 200;
    return Response.json(result.response ?? { success: true }, {
        status,
        headers: result.responseHeaders,
    });
}
```

## Events

## Bounces

### Created

`bounces.created`

A campaign or transactional email bounced (bounces/new), with the SMTP response.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `email_id` | `string \| null` | No | — |
| `subscriber` | `object \| null` | No | — |
| `email_campaign_data` | `object \| null` | No | — |
| `transactional_campaign_id` | `string \| number \| null` | No | — |
| `transactional_campaign_data` | `object \| null` | No | — |

> [accordion] subscriber full type
>
> ```ts theme={null}
> {
>   id?: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> } | null
> ```

> [accordion] email\_campaign\_data full type
>
> ```ts theme={null}
> {
>   campaign_id?: string | number | null,
>   smtp_response?: string | null
> } | null
> ```

> [accordion] transactional\_campaign\_data full type
>
> ```ts theme={null}
> {
>   domain_id?: string | number | null,
>   smtp_response?: string | null,
>   variables?: Record<string, any> | null
> } | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   email_id?: string | null,
>   subscriber?: {
>     id?: string | number,
>     email?: string | null,
>     firstname?: string | null,
>     lastname?: string | null,
>     phone?: string | null,
>     phone_country?: {
>       phone_code?: number | null,
>       country_code?: string | null
>     } | null,
>     created?: string | null,
>     status?: Record<string, any> | null,
>     ip_address?: string | null,
>     bounced_at?: string | null,
>     unsubscribed_at?: string | null,
>     unsubscribed?: boolean | number | null,
>     bounced?: boolean | number | null,
>     spam_reported?: boolean | number | null,
>     location?: any,
>     source?: string | null,
>     subscriber_tags?: (
>       {
>         id?: string | number | null,
>         title?: string | null
>       } | string
>     )[] | null,
>     columns?: {
>       id?: string | number | null,
>       title?: string | null,
>       type?: string | null,
>       default?: boolean | number | null,
>       value?: any
>     }[] | Record<string, any> | null,
>     sms_campaign?: Record<string, any> | null,
>     email_campaign?: Record<string, any> | null
>   } | null,
>   email_campaign_data?: {
>     campaign_id?: string | number | null,
>     smtp_response?: string | null
>   } | null,
>   transactional_campaign_id?: string | number | null,
>   transactional_campaign_data?: {
>     domain_id?: string | number | null,
>     smtp_response?: string | null,
>     variables?: Record<string, any> | null
>   } | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        bounces: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Campaigns

### Created

`campaigns.created`

A campaign was created (campaigns/new).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `title` | `string \| null` | No | — |
| `subject` | `string \| null` | No | — |
| `from` | `string \| null` | No | — |
| `reply_to` | `string \| null` | No | — |

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   title?: string | null,
>   subject?: string | null,
>   from?: string | null,
>   reply_to?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        campaigns: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Groups

### Created

`groups.created`

A group was created (groups/new).

**Payload**

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

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   title?: string | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        groups: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Subscriber Added

`groups.subscriberAdded`

A subscriber joined the group the webhook watches (groups/new-subscriber).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `email` | `string \| null` | No | — |
| `firstname` | `string \| null` | No | — |
| `lastname` | `string \| null` | No | — |
| `phone` | `string \| null` | No | — |
| `phone_country` | `object \| null` | No | — |
| `created` | `string \| null` | No | — |
| `status` | `Record<string, any> \| null` | No | — |
| `ip_address` | `string \| null` | No | — |
| `bounced_at` | `string \| null` | No | — |
| `unsubscribed_at` | `string \| null` | No | — |
| `unsubscribed` | `boolean \| number \| null` | No | — |
| `bounced` | `boolean \| number \| null` | No | — |
| `spam_reported` | `boolean \| number \| null` | No | — |
| `location` | `any` | No | — |
| `source` | `string \| null` | No | — |
| `subscriber_tags` | `object[] \| null` | No | — |
| `columns` | `object[] \| Record<string, any> \| null` | No | — |
| `sms_campaign` | `Record<string, any> \| null` | No | — |
| `email_campaign` | `Record<string, any> \| null` | No | — |

> [accordion] phone\_country full type
>
> ```ts theme={null}
> {
>   phone_code?: number | null,
>   country_code?: string | null
> } | null
> ```

> [accordion] subscriber\_tags full type
>
> ```ts theme={null}
> (
>   {
>     id?: string | number | null,
>     title?: string | null
>   } | string
> )[] | null
> ```

> [accordion] columns full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   title?: string | null,
>   type?: string | null,
>   default?: boolean | number | null,
>   value?: any
> }[] | Record<string, any> | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        groups: {
            subscriberAdded: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Subscriber Unsubscribed

`groups.subscriberUnsubscribed`

A subscriber left the group the webhook watches (groups/unsubscribed).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `email` | `string \| null` | No | — |
| `firstname` | `string \| null` | No | — |
| `lastname` | `string \| null` | No | — |
| `phone` | `string \| null` | No | — |
| `phone_country` | `object \| null` | No | — |
| `created` | `string \| null` | No | — |
| `status` | `Record<string, any> \| null` | No | — |
| `ip_address` | `string \| null` | No | — |
| `bounced_at` | `string \| null` | No | — |
| `unsubscribed_at` | `string \| null` | No | — |
| `unsubscribed` | `boolean \| number \| null` | No | — |
| `bounced` | `boolean \| number \| null` | No | — |
| `spam_reported` | `boolean \| number \| null` | No | — |
| `location` | `any` | No | — |
| `source` | `string \| null` | No | — |
| `subscriber_tags` | `object[] \| null` | No | — |
| `columns` | `object[] \| Record<string, any> \| null` | No | — |
| `sms_campaign` | `Record<string, any> \| null` | No | — |
| `email_campaign` | `Record<string, any> \| null` | No | — |

> [accordion] phone\_country full type
>
> ```ts theme={null}
> {
>   phone_code?: number | null,
>   country_code?: string | null
> } | null
> ```

> [accordion] subscriber\_tags full type
>
> ```ts theme={null}
> (
>   {
>     id?: string | number | null,
>     title?: string | null
>   } | string
> )[] | null
> ```

> [accordion] columns full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   title?: string | null,
>   type?: string | null,
>   default?: boolean | number | null,
>   value?: any
> }[] | Record<string, any> | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        groups: {
            subscriberUnsubscribed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

## Subscribers

### Created

`subscribers.created`

A subscriber was added (subscribers/new).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `email` | `string \| null` | No | — |
| `firstname` | `string \| null` | No | — |
| `lastname` | `string \| null` | No | — |
| `phone` | `string \| null` | No | — |
| `phone_country` | `object \| null` | No | — |
| `created` | `string \| null` | No | — |
| `status` | `Record<string, any> \| null` | No | — |
| `ip_address` | `string \| null` | No | — |
| `bounced_at` | `string \| null` | No | — |
| `unsubscribed_at` | `string \| null` | No | — |
| `unsubscribed` | `boolean \| number \| null` | No | — |
| `bounced` | `boolean \| number \| null` | No | — |
| `spam_reported` | `boolean \| number \| null` | No | — |
| `location` | `any` | No | — |
| `source` | `string \| null` | No | — |
| `subscriber_tags` | `object[] \| null` | No | — |
| `columns` | `object[] \| Record<string, any> \| null` | No | — |
| `sms_campaign` | `Record<string, any> \| null` | No | — |
| `email_campaign` | `Record<string, any> \| null` | No | — |

> [accordion] phone\_country full type
>
> ```ts theme={null}
> {
>   phone_code?: number | null,
>   country_code?: string | null
> } | null
> ```

> [accordion] subscriber\_tags full type
>
> ```ts theme={null}
> (
>   {
>     id?: string | number | null,
>     title?: string | null
>   } | string
> )[] | null
> ```

> [accordion] columns full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   title?: string | null,
>   type?: string | null,
>   default?: boolean | number | null,
>   value?: any
> }[] | Record<string, any> | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        subscribers: {
            created: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Unsubscribed

`subscribers.unsubscribed`

A subscriber unsubscribed (subscribers/unsubscribed).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `email` | `string \| null` | No | — |
| `firstname` | `string \| null` | No | — |
| `lastname` | `string \| null` | No | — |
| `phone` | `string \| null` | No | — |
| `phone_country` | `object \| null` | No | — |
| `created` | `string \| null` | No | — |
| `status` | `Record<string, any> \| null` | No | — |
| `ip_address` | `string \| null` | No | — |
| `bounced_at` | `string \| null` | No | — |
| `unsubscribed_at` | `string \| null` | No | — |
| `unsubscribed` | `boolean \| number \| null` | No | — |
| `bounced` | `boolean \| number \| null` | No | — |
| `spam_reported` | `boolean \| number \| null` | No | — |
| `location` | `any` | No | — |
| `source` | `string \| null` | No | — |
| `subscriber_tags` | `object[] \| null` | No | — |
| `columns` | `object[] \| Record<string, any> \| null` | No | — |
| `sms_campaign` | `Record<string, any> \| null` | No | — |
| `email_campaign` | `Record<string, any> \| null` | No | — |

> [accordion] phone\_country full type
>
> ```ts theme={null}
> {
>   phone_code?: number | null,
>   country_code?: string | null
> } | null
> ```

> [accordion] subscriber\_tags full type
>
> ```ts theme={null}
> (
>   {
>     id?: string | number | null,
>     title?: string | null
>   } | string
> )[] | null
> ```

> [accordion] columns full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   title?: string | null,
>   type?: string | null,
>   default?: boolean | number | null,
>   value?: any
> }[] | Record<string, any> | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        subscribers: {
            unsubscribed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Updated

`subscribers.updated`

A subscriber was changed (subscribers/updated).

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `string \| number` | Yes | — |
| `email` | `string \| null` | No | — |
| `firstname` | `string \| null` | No | — |
| `lastname` | `string \| null` | No | — |
| `phone` | `string \| null` | No | — |
| `phone_country` | `object \| null` | No | — |
| `created` | `string \| null` | No | — |
| `status` | `Record<string, any> \| null` | No | — |
| `ip_address` | `string \| null` | No | — |
| `bounced_at` | `string \| null` | No | — |
| `unsubscribed_at` | `string \| null` | No | — |
| `unsubscribed` | `boolean \| number \| null` | No | — |
| `bounced` | `boolean \| number \| null` | No | — |
| `spam_reported` | `boolean \| number \| null` | No | — |
| `location` | `any` | No | — |
| `source` | `string \| null` | No | — |
| `subscriber_tags` | `object[] \| null` | No | — |
| `columns` | `object[] \| Record<string, any> \| null` | No | — |
| `sms_campaign` | `Record<string, any> \| null` | No | — |
| `email_campaign` | `Record<string, any> \| null` | No | — |

> [accordion] phone\_country full type
>
> ```ts theme={null}
> {
>   phone_code?: number | null,
>   country_code?: string | null
> } | null
> ```

> [accordion] subscriber\_tags full type
>
> ```ts theme={null}
> (
>   {
>     id?: string | number | null,
>     title?: string | null
>   } | string
> )[] | null
> ```

> [accordion] columns full type
>
> ```ts theme={null}
> {
>   id?: string | number | null,
>   title?: string | null,
>   type?: string | null,
>   default?: boolean | number | null,
>   value?: any
> }[] | Record<string, any> | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   id: string | number,
>   email?: string | null,
>   firstname?: string | null,
>   lastname?: string | null,
>   phone?: string | null,
>   phone_country?: {
>     phone_code?: number | null,
>     country_code?: string | null
>   } | null,
>   created?: string | null,
>   status?: Record<string, any> | null,
>   ip_address?: string | null,
>   bounced_at?: string | null,
>   unsubscribed_at?: string | null,
>   unsubscribed?: boolean | number | null,
>   bounced?: boolean | number | null,
>   spam_reported?: boolean | number | null,
>   location?: any,
>   source?: string | null,
>   subscriber_tags?: (
>     {
>       id?: string | number | null,
>       title?: string | null
>     } | string
>   )[] | null,
>   columns?: {
>     id?: string | number | null,
>     title?: string | null,
>     type?: string | null,
>     default?: boolean | number | null,
>     value?: any
>   }[] | Record<string, any> | null,
>   sms_campaign?: Record<string, any> | null,
>   email_campaign?: Record<string, any> | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
sender({
    webhookHooks: {
        subscribers: {
            updated: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


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