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

# Fluxguard webhooks

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

The Fluxguard plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/fluxguard/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

* `change`
  * `detected` (`change.detected`)

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

## Change

### Detected

`change.detected`

A monitored page changed: Fluxguard posts the captured version with references to its HTML, screenshot and diff files

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `url` | `string \| null` | No | URL where the change was detected |
| `finalUrl` | `string \| null` | No | URL after redirects |
| `capturedAt` | `string \| null` | No | When the version was captured |
| `comparisonType` | `string \| null` | No | HTML, visual, text or network |
| `orgId` | `string \| null` | No | — |
| `orgName` | `string \| null` | No | — |
| `title` | `string \| null` | No | Title of the page |
| `statusCode` | `number \| null` | No | — |
| `aiFlagged` | `string \| null` | No | warning for a significant change, serenity otherwise |
| `summary` | `string \| null` | No | AI summary of the captured version |
| `diffSummary` | `string \| null` | No | AI summary of what changed since the previous version |
| `diffUrl` | `string \| null` | No | Console URL for this version |
| `fileBaseUrl` | `string \| null` | No | Prefix to append every filename under files to |
| `site` | `object \| null` | No | — |
| `session` | `object \| null` | No | — |
| `page` | `object \| null` | No | — |
| `siteCategories` | `string[] \| null` | No | Category names, e.g. \["News"] |
| `pageCategories` | `string[] \| null` | No | Category names, e.g. \["News"] |
| `files` | `Record<string, any> \| null` | No | — |
| `alarms` | `Record<string, any>[] \| null` | No | — |

> [accordion] site full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   origin?: string | null,
>   nickname?: string | null
> } | null
> ```

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

> [accordion] page full type
>
> ```ts theme={null}
> {
>   id?: string | null,
>   path?: string | null
> } | null
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   url?: string | null,
>   finalUrl?: string | null,
>   capturedAt?: string | null,
>   comparisonType?: string | null,
>   orgId?: string | null,
>   orgName?: string | null,
>   title?: string | null,
>   statusCode?: number | null,
>   aiFlagged?: string | null,
>   summary?: string | null,
>   diffSummary?: string | null,
>   diffUrl?: string | null,
>   fileBaseUrl?: string | null,
>   site?: {
>     id?: string | null,
>     origin?: string | null,
>     nickname?: string | null
>   } | null,
>   session?: {
>     id?: string | null,
>     name?: string | null
>   } | null,
>   page?: {
>     id?: string | null,
>     path?: string | null
>   } | null,
>   siteCategories?: string[] | null,
>   pageCategories?: string[] | null,
>   files?: Record<string, any> | null,
>   alarms?: Record<string, any>[] | null
> }
> ```

**`webhookHooks` example**

```ts theme={null}
fluxguard({
    webhookHooks: {
        change: {
            detected: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


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