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

# Moz webhooks

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

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

* `locations`
  * `canceled` (`locations.canceled`)
  * `closed` (`locations.closed`)
  * `created` (`locations.created`)
  * `updated` (`locations.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

## Locations

### Canceled

`locations.canceled`

A Moz Local location was canceled; carries the location\_id to read with local.locations.lookup

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `string` | Yes | — |
| `timestamp` | `string \| null` | No | — |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   location_id: number
> }
> ```

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

**`webhookHooks` example**

```ts theme={null}
moz({
    webhookHooks: {
        locations: {
            canceled: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Closed

`locations.closed`

A Moz Local location was closed (permanently closed); carries the location\_id to read with local.locations.lookup

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `string` | Yes | — |
| `timestamp` | `string \| null` | No | — |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   location_id: number
> }
> ```

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

**`webhookHooks` example**

```ts theme={null}
moz({
    webhookHooks: {
        locations: {
            closed: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Created

`locations.created`

A Moz Local location was created; carries the location\_id to read with local.locations.lookup

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `string` | Yes | — |
| `timestamp` | `string \| null` | No | — |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   location_id: number
> }
> ```

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

**`webhookHooks` example**

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

***

### Updated

`locations.updated`

A Moz Local location was updated; carries the location\_id to read with local.locations.lookup

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `type` | `string` | Yes | — |
| `timestamp` | `string \| null` | No | — |
| `data` | `object` | Yes | — |

> [accordion] data full type
>
> ```ts theme={null}
> {
>   location_id: number
> }
> ```

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

**`webhookHooks` example**

```ts theme={null}
moz({
    webhookHooks: {
        locations: {
            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.