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

# Webhooks

> Saperly incoming webhooks: event paths, payloads, and response data.

The Saperly plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](/plugins/saperly/overview) for setup context and the exact URL shape).

> [!NOTE]
>
> **New to Corsair?** See [webhooks](/concepts/webhooks) and [hooks](/concepts/hooks).

## Webhook map

* `events`
  * `delivery` (`events.delivery`)

## 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);
    const body = await request.json();
    const result = await processWebhook(corsair, headers, body);
    return result.response;
}
```

## Events

## Events

### Delivery

`events.delivery`

Signed call and SMS deliveries. The handler confirms the resource with the API before returning success.

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `deliveryId` | `string` | Yes | — |
| `eventType` | `string` | Yes | — |
| `payload` | `object` | Yes | — |

> **payload full type**
>
> ```ts theme={null}
> {
>   callId?: string,
>   messageId?: string,
>   numberId?: string
> }
> ```

> **Response data full type**
>
> ```ts theme={null}
> {
>   eventType: string,
>   deliveryId: string,
>   resource: {
>   }
> }
> ```

**`webhookHooks` example**

```ts theme={null}
saperly({
    webhookHooks: {
        events: {
            delivery: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


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