---
title: "Webhooks"
description: "Manage webhook endpoints and verify signed webhook deliveries with @wazapin/sdk."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.wazapin.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

There are two webhook surfaces:

- `wazapin.webhooks` manages webhook endpoints and deliveries.
- `@wazapin/sdk/webhooks` verifies signed deliveries on your server.

## Manage webhook endpoints

```ts
const settings = await wazapin.webhooks.listSettings();

const { data: endpoint } = await wazapin.webhooks.createEndpoint({
  url: "https://yourapp.com/webhooks/wazapin",
  event_types: ["message.new", "message.status_update"],
});

await wazapin.webhooks.test(endpoint.id);
```

## Rotate a signing secret

```ts
const { data } = await wazapin.webhooks.rotateSecret("endpoint_123");

console.log(data.signing_secret);
```

## Retry a delivery

```ts
const deliveries = await wazapin.webhooks.listDeliveries({ limit: 50 });
await wazapin.webhooks.retryDelivery("msg_123");
```

## Verify webhook signatures

Install the optional peer dependency:

```bash
npm install @wazapin/sdk svix
```

```ts
import { parseWebhookEvent, verifyWebhook } from "@wazapin/sdk/webhooks";

const verified = verifyWebhook(
  rawBody,
  req.headers,
  process.env.WAZAPIN_WEBHOOK_SECRET!,
);

const event = parseWebhookEvent(verified.eventType, verified.body);
```

:::warning
Verify the signature using the raw request body. Do not verify a re-serialized JSON object.
:::

Source: https://docs.wazapin.id/sdk/webhooks/index.mdx
