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

# Webhooks

> Verify incoming UQPAY webhook signatures with the Python SDK.

Set `webhook_secret` when you create the client, then pass the unmodified request body and headers to `construct_event`.

Before implementing verification, [configure a notification URL](/account-center/v1.6/guide/webhooks-setting) and review the [webhook delivery and security model](/account-center/v1.6/guide/webhooks-overview).

```python theme={null}
client = UQPayClient(
    client_id="your-client-id",
    api_key="your-api-key",
    webhook_secret="your-webhook-secret",
)

# In your HTTP handler:
from uqpay import UQPayWebhookError

try:
    event = client.webhooks.construct_event(
        raw_body=request.get_data(),
        headers=dict(request.headers),
    )
    print(event["event_type"], event["data"])
except UQPayWebhookError as e:
    return str(e), 400
```

<Warning>
  Pass the original raw request body. Parsing and re-serializing JSON before verification changes the signed bytes and causes verification to fail.
</Warning>

The verifier checks the webhook signature and rejects requests with a timestamp outside the five-minute replay window.
