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

# Webhooks

> Set up and manage webhooks

Webhooks allow you to receive real-time notifications when events occur in your tenant.

## Setting Up Webhooks

1. **Create Webhook Endpoint**

<RequestExample>
  ```bash theme={null}
  curl -X POST https://cp.gosentrix.io/api/v1/tenants/{tenant_id}/webhooks \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -d '{
      "url": "https://example.com/webhook",
      "events": ["user.created", "user.updated"],
      "secret": "your-webhook-secret"
    }'
  ```
</RequestExample>

2. **Verify Webhook Signature**

Webhooks include an HMAC signature in the `X-Webhook-Signature` header:

```javascript theme={null}
const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const hmac = crypto.createHmac('sha256', secret);
  const digest = hmac.update(payload).digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(digest)
  );
}
```

3. **Handle Events**

Process incoming webhook events and respond with `200 OK` within 5 seconds.

## Webhook Events

See [Webhook Events Reference](/reference/webhook-events) for available events.

## Retries

Failed webhook deliveries are automatically retried. See [Webhook Retries](/webhooks/retries) for details.

## Security

* Always verify webhook signatures
* Use HTTPS for webhook URLs
* Rotate webhook secrets regularly
* Validate event payloads
