
## Register an endpoint

{{op createWebhook}} with a public `https://` URL and the events you want. The response carries the `signing_secret` once. Private, loopback and link-local addresses (including `169.254.169.254`) are rejected; Payezy resolves the host before it connects.

Events are delivered to endpoints on the organization the event is about. A platform receives `platform_customer.updated` on its own endpoints; a customer's payment and verification events go to endpoints on the customer's organization. See [reconcile across customers](/guides/reconcile/).

## Events

{{events}}

## Verify every delivery

Each delivery has these headers:

| Header | Value |
| --- | --- |
| `Payezy-Event` | The event type |
| `Payezy-Signature` | `t=<unix seconds>,v1=<hex HMAC-SHA256>` |
| `Content-Type` | `application/json` |

The signed string is `<t>.<raw body>`. Compute the HMAC with your signing secret over the **raw** bytes, before any JSON parsing, and compare in constant time. Reject timestamps older than five minutes. During the 24 hours after you rotate the secret, the header has two `v1` values; accept either.

```js
import crypto from "node:crypto";

export function verify(rawBody, header, secret, toleranceSeconds = 300) {
  const parts = header.split(",").map((p) => p.split("="));
  const t = Number(parts.find(([k]) => k === "t")?.[1]);
  const sigs = parts.filter(([k]) => k === "v1").map(([, v]) => v);
  if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return sigs.some((s) => s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}
```

```python
import hmac, hashlib, time

def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    parts = [p.split("=", 1) for p in header.split(",")]
    t = int(next((v for k, v in parts if k == "t"), "0"))
    sigs = [v for k, v in parts if k == "v1"]
    if not t or abs(time.time() - t) > tolerance:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(s, expected) for s in sigs)
```

## Retries and replay

Answer with any `2xx` within a few seconds and do the work afterwards. Failed deliveries retry with backoff and the endpoint is marked `failing` after repeated errors. {{op listWebhookDeliveries}} shows attempts; {{op replayWebhookDelivery}} queues one again.

Events can arrive more than once and out of order. Treat them as signals: use the `id` to fetch the current state when order matters.

## Rotation

{{op rotateWebhookSecret}} mints a new secret. The previous one keeps verifying for 24 hours, so deploy the new secret within that window.
