# Webhooks and events

The events Abazi emits, how webhook deliveries are signed and retried, and how to verify, replay and debug them.

<ShortProductTruth>Every state change in Abazi is an event. Organizations and merchants receive the events they subscribe to as signed webhooks, retried on a fixed schedule and replayable on demand.</ShortProductTruth>

## Events you can subscribe to [#events-you-can-subscribe-to]

Each event has its own page with when it fires and an example payload.

<EventTable />

## Signing [#signing]

Deliveries follow the Standard Webhooks scheme. Each request carries three headers:

| Header | Content |
| --- | --- |
| `webhook-id` | The event id; the same on every retry of that event, so you can de-duplicate. |
| `webhook-timestamp` | Unix seconds when the attempt was sent. Reject old timestamps to stop replays by a third party. |
| `webhook-signature` | `v1,<base64 HMAC-SHA256>` over `id.timestamp.body`, keyed with your endpoint's signing secret. |

The signing secret starts with `whsec_` and is shown once when you create the endpoint. You can rotate it at any time.

Verify every delivery before you act on it. In Python:

```python title="Verify a delivery"
import base64, hashlib, hmac

def verify(secret: str, msg_id: str, timestamp: str, body: bytes, header: str) -> bool:
    key = base64.b64decode(secret.removeprefix("whsec_"))
    signed = f"{msg_id}.{timestamp}.".encode() + body
    expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    return any(hmac.compare_digest(expected, part.split(",", 1)[1])
               for part in header.split() if part.startswith("v1,"))
```

## Retries [#retries]

A delivery that does not get a 2xx answer is retried up to seven more times: after 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 10 hours. After the last attempt it is marked dead. Each attempt, with its response code, is kept and visible in the Console.

<StateMachine name="webhook_delivery" />

## Replay and test [#replay-and-test]

- **Replay** any event to one endpoint or to all, for example after fixing a handler.
- **Send a test event** to a new endpoint to check your signature verification before real events arrive.
- **Request logs** keep API and MCP calls for seven days, redacted.

<Screenshot id="developers-events" />

## Next steps [#next-steps]

<Cards>
  <Card title="Developer Platform" href="/docs/products/developer-platform" description="Keys, test mode, logs and webhooks as one product." />
  <Card title="State machines" href="/docs/api/state-machines" description="Which state changes produce which events." />
  <Card title="API reference" href="/docs/api" description="The Abazi API operations that manage webhook endpoints and events." />
</Cards>

