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

# Webhooks

> Get a signed message at your own address whenever something happens in your organization, such as a sign-in or a role change.

Webhooks tell your app what happened in your Aiveth organization as it happens: someone joined, signed in, changed role, or withdrew consent. Aiveth posts a signed JSON message to an `https` address you choose and retries until your app accepts it.

> [!NOTE]
>
> Webhooks are available on the Pro plan and above.

## Add a webhook address

**1. Open Webhooks**

In the console, go to **Webhooks** and choose **Add webhook address**. This needs the **Manage apps** power.

**2. Enter the address**

The **Address** must be an `https` address on the public internet. Add a **Note** if you like.

**3. Choose events**

Under **Events to send**, choose **All events** or pick the [event types](https://docs.aiveth.com/events/event-types.md) you want. Choose at least one.

**4. Copy the signing secret**

Aiveth shows the address's signing secret (`whsec_...`) once. Your app uses it to check each message came from Aiveth.

**5. Send a test**

Choose **Send a test**. Aiveth sends a `webhook.test` message right away and shows what came back.

An organization can have up to 10 webhook addresses.

> [!NOTE]
>
> Sign-in events (`session.created`, `session.revoked`, `authentication.failed`, `impersonation.started`, `impersonation.ended`) tell who signed in and from where. Choosing them also needs the **See sign-in history** power.

## The message

Every message is one event:

```json theme={null}
{
  "object": "event",
  "id": "...",
  "type": "organization_membership.updated",
  "timestamp": "2026-11-24T10:15:00+00:00",
  "organization_id": "...",
  "data": {
    "object": "organization_membership",
    "user_id": "...",
    "organization_id": "...",
    "role": "admin",
    "previous_attributes": { "role": "member" }
  }
}
```

* `data` is the object as it is now. It never contains a password, code, token or link.
* An update includes `previous_attributes` when Aiveth knows what it was before.
* Events are made in the same database transaction as the change they describe, so none is missed, and an event exists only if its change happened.

## Verify the signature

Aiveth signs every message the way Standard Webhooks does. Each request has three headers:

| Header | Value |
| - | - |
| `webhook-id` | A unique message ID. |
| `webhook-timestamp` | When it was sent, in Unix seconds. |
| `webhook-signature` | `v1,` followed by the base64 HMAC-SHA256 of `{id}.{timestamp}.{body}`, keyed with your secret (the part after `whsec_`, base64-decoded). Several signatures are separated by spaces while a secret is being replaced. |

The User-Agent is `Aiveth-Webhooks/1`.

Use the SDK, and pass the **raw** request body. Parsing and re-serializing the JSON changes the bytes and breaks the signature.

```ts Node theme={null}
import express from 'express';
import { verifyWebhook } from '@gooclaim/aiveth';

app.post('/webhooks/aiveth', express.raw({ type: 'application/json' }), (req, res) => {
  try {
    const event = verifyWebhook(req.body, req.headers, process.env.AIVETH_WEBHOOK_SECRET!);
    // handle event.type ...
    res.sendStatus(204);
  } catch {
    res.sendStatus(400);
  }
});
```

```python Python theme={null}
from gooclaim_aiveth_sdk import WebhookVerificationError, verify_webhook

@app.post("/webhooks/aiveth")
async def aiveth_webhook(request: Request):
    try:
        event = verify_webhook(await request.body(), request.headers, os.environ["AIVETH_WEBHOOK_SECRET"])
    except WebhookVerificationError:
        return Response(status_code=400)
    # handle event["type"] ...
    return Response(status_code=204)
```

The SDK rejects a message whose timestamp is more than 5 minutes from now, either way.

> [!TIP]
>
> A message can arrive more than once. Keep the `webhook-id`s you have handled and skip repeats.

### Replace a secret

Choose **New signing secret** on the address. The old secret keeps signing beside the new one for 24 hours, so you can switch your app without missing anything.

## Retries

| Your answer | What Aiveth does |
| - | - |
| Any `2xx` | Delivered. |
| `410 Gone` | Your app wants no more: the address is turned off at once. |
| `429`, `502`, `503`, `504` | Busy: tried again later, after your `Retry-After` header if you send one (up to a day). |
| Anything else, a timeout, or a `3xx` | Failed: tried again on the schedule. Aiveth never follows redirects. |

After the first try, Aiveth tries again after about 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, 14 hours, 20 hours and 24 hours, about 3 days in all. Each wait is shifted a little at random.

An address that has had nothing but failures for 5 days is turned off, and your Owners are told. Turn it back on from **Webhooks** when it is fixed.

### See and resend deliveries

Open an address to see **What was sent**: the last 50 deliveries and what came back.

* **Resend** one failed delivery.
* **Resend everything since** a date: sends again what failed, and what this address missed while it was off.

Events are kept for 30 days.

## Where Aiveth posts from

To keep webhooks from reaching private networks, Aiveth:

* posts only to `https` addresses on port 443 or 8443, up to 2,048 characters, with no user name or password in them,
* posts only to hosts that resolve to public internet addresses, never private, loopback or cloud metadata ranges,
* connects to the exact IP address it checked, while still verifying your certificate for the host name, so a DNS answer that changes in between reaches nothing new,
* never follows redirects and never reads your response body.

Each post has one overall deadline of 20 seconds.

## Read events back

Your server can also read the same events with an [API key](https://docs.aiveth.com/account/api-keys.md) that has the `events:read` power:

```bash theme={null}
curl "https://accounts.aiveth.com/v1/events?types=user.created,user.updated&limit=10" \
  -H "Authorization: Bearer aiveth_sk_live_..."
```

Results come oldest first. Page on with `after=<list_metadata.after>`, or start from a time with `range_start=2026-11-09T00:00:00Z` (not both). `limit` defaults to 10, up to 100. An event shows up once it is 30 seconds old, so a change still being saved is never skipped. The Node SDK has `aiveth.events.list()`.


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