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

# Webhooks

> Hear about purchases, refunds and achievement unlocks on your server, as signed HTTPS requests.

Webhooks tell your server when something happens to your game on Gamavas, so you don't have to poll.

| Event | When |
| - | - |
| `order.paid` | Someone bought your game, by card or with coins |
| `order.refunded` | A purchase was refunded or charged back |
| `entitlement.revoked` | A player no longer owns your game |
| `achievement.unlocked` | A player unlocked one of your achievements |
| `webhook.test` | You pressed **Send test event** in the portal |

Each event's exact fields are in the API reference, under **Webhooks**.

## Add an endpoint

On your app's **Webhooks** page in the [developer portal](https://developer.gamavas.fun), add your server's public `https://` address and pick the events it wants. You get a **signing secret** (`whsec_…`). An app can have up to 5 endpoints. Press **Send test event** to check it works.

## What Gamavas sends

A `POST` with a JSON body:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "evt_…",
  "type": "order.paid",
  "createdAt": "2026-12-01T10:00:00.000Z",
  "appId": "…",
  "livemode": true,
  "data": { "orderId": "…", "playerId": "…", "method": "card", "priceCents": 499, … }
}
```

`livemode` is `false` for test purchases and test events. The headers include `Gamavas-Event`, `Gamavas-Event-Id` and `Gamavas-Signature`.

## Verify the signature

Check every request before trusting it, using the **raw** body:

```ts @gamavas/pass-server theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { verifyWebhook } from "@gamavas/pass-server";

app.post("/gamavas", express.raw({ type: "application/json" }), async (req, res) => {
  const event = await verifyWebhook({
    body: req.body,                              // the raw bytes, not parsed JSON
    signature: req.headers["gamavas-signature"],
    secret: process.env.GAMAVAS_WEBHOOK_SECRET,
  });
  if (event.type === "order.paid") grantGame(event.data.playerId);
  res.sendStatus(200);
});
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import hashlib, hmac, time

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    t, signature = int(parts["t"]), parts["v1"]
    if abs(time.time() - t) > 300:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)
```

The header is `t=<unix seconds>,v1=<signature>`, where the signature is the hex HMAC-SHA256 of `<t>.<raw body>` with your signing secret. Refuse requests more than 5 minutes old, and compare in constant time.

## Answer quickly, and expect retries

Answer any `2xx` within **10 seconds**. Do slow work afterwards. If your server fails or times out, Gamavas retries after 1 minute, 5 minutes, 30 minutes, then 2, 6 and 12 hours: about a day in all.

The event `id` stays the same on every retry, so skip IDs you've already handled. The **Webhooks** page shows every delivery, with its status and your server's answer, and you can resend any of them.

> [!TIP]
>
> Rotate the signing secret from the Webhooks page if it leaks. Your old secret stops working at once.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.