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

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

The PostHog plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](/plugins/posthog/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`
  * `captured` (`events.captured`)

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

### Captured

`events.captured`

A PostHog event was captured

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `string` | Yes | — |
| `distinct_id` | `string` | Yes | — |
| `timestamp` | `string` | No | — |
| `uuid` | `string` | No | — |
| `properties` | `object` | No | — |
| `person` | `object` | No | — |
| `groups` | `object` | No | — |
| `$set` | `object` | No | — |
| `$set_once` | `object` | No | — |
| `$unset` | `string[]` | No | — |

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

  <Accordion title="person full type">
    ```ts theme={null}
    {
      distinct_id: string,
      properties?: {
      }
    }
    ```
  </Accordion>

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

  <Accordion title="$set full type">
    ```ts theme={null}
    {
    }
    ```
  </Accordion>

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

<AccordionGroup>
  <Accordion title="Response data full type">
    ```ts theme={null}
    {
      event: string,
      distinct_id: string,
      timestamp?: string,
      uuid?: string,
      properties?: {
      },
      person?: {
        distinct_id: string,
        properties?: {
        }
      },
      groups?: {
      },
      $set?: {
      },
      $set_once?: {
      },
      $unset?: string[]
    }
    ```
  </Accordion>
</AccordionGroup>

**`webhookHooks` example**

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

***


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