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

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

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

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

## Webhook map

* `events`
  * `monitor` (`events.monitor`)
  * `test` (`events.test`)

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

### Monitor

`events.monitor`

Handle a signed Xquik monitor event delivery

**Payload**

| Name            | Type                                                                       | Required | Description |
| --------------- | -------------------------------------------------------------------------- | -------- | ----------- |
| `data`          | `object`                                                                   | Yes      | —           |
| `deliveryId`    | `string`                                                                   | No       | —           |
| `eventType`     | `tweet.new \| tweet.quote \| tweet.reply \| tweet.retweet \| webhook.test` | Yes      | —           |
| `occurredAt`    | `string`                                                                   | No       | —           |
| `query`         | `string`                                                                   | No       | —           |
| `schemaVersion` | `string`                                                                   | No       | —           |
| `streamEventId` | `string`                                                                   | No       | —           |
| `timestamp`     | `string`                                                                   | No       | —           |
| `username`      | `string`                                                                   | No       | —           |

<AccordionGroup>
  <Accordion title="data full type">
    ```ts theme={null}
    {
    }
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      data: {
      },
      deliveryId?: string,
      eventType: tweet.new | tweet.quote | tweet.reply | tweet.retweet | webhook.test,
      occurredAt?: string,
      query?: string,
      schemaVersion?: string,
      streamEventId?: string,
      timestamp?: string,
      username?: string
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

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

***

### Test

`events.test`

Handle a signed Xquik test webhook delivery

**Payload**

| Name            | Type                                                                       | Required | Description |
| --------------- | -------------------------------------------------------------------------- | -------- | ----------- |
| `data`          | `object`                                                                   | Yes      | —           |
| `deliveryId`    | `string`                                                                   | No       | —           |
| `eventType`     | `tweet.new \| tweet.quote \| tweet.reply \| tweet.retweet \| webhook.test` | Yes      | —           |
| `occurredAt`    | `string`                                                                   | No       | —           |
| `query`         | `string`                                                                   | No       | —           |
| `schemaVersion` | `string`                                                                   | No       | —           |
| `streamEventId` | `string`                                                                   | No       | —           |
| `timestamp`     | `string`                                                                   | No       | —           |
| `username`      | `string`                                                                   | No       | —           |

<AccordionGroup>
  <Accordion title="data full type">
    ```ts theme={null}
    {
    }
    ```
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      data: {
      },
      deliveryId?: string,
      eventType: tweet.new | tweet.quote | tweet.reply | tweet.retweet | webhook.test,
      occurredAt?: string,
      query?: string,
      schemaVersion?: string,
      streamEventId?: string,
      timestamp?: string,
      username?: string
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

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

***
