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

# Webhooks

> How Agentcard events reach your server: connect an endpoint, verify the signature, and handle retries.

Everything that happens to your connected users reaches your server as a webhook: a card stored in the Vault, a checkout approved, an order placed, an identity check finished. SDK callbacks are UI signals. Webhooks are the record.

## Connect an endpoint

Register a URL and the events it should receive. Do it once per mode: a sandbox token registers a sandbox endpoint, a production token a production one.

```bash theme={null}
curl -X POST https://api.agentcard.sh/api/v2/webhook_endpoints \
  -H "Authorization: Bearer $ORG_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://your.app/agentcard/webhooks", "enabled_events": ["vault.*", "checkout_authorization.*", "order.*"]}'
```

The response carries the endpoint's `secret` once. Store it. `enabled_events` takes exact names, prefix wildcards like `vault.*`, or `["*"]` for everything. An endpoint receives only what it lists.

Manage endpoints, read or rotate the secret, and inspect recent deliveries with the [Webhook endpoints API](https://docs.agentcard.com/api-reference/webhook-endpoints/overview.md). The same is available in the dashboard under Developers → Webhooks.

## The envelope

Every event has the same shape:

```json theme={null}
{
  "id": "evt_9f8e7d6c5b4a",
  "type": "vault.card_stored",
  "created": 1757264400,
  "livemode": false,
  "data": { }
}
```

`type` is stable and part of the API contract, so branch on it directly. `livemode: false` is sandbox. Delivery is at least once, so deduplicate on `id`.

## Keep only your own events

Every endpoint in your company receives every event of its mode. To run a staging and a production backend against one company, give each backend its own OAuth client and read `data.origin.client_id` on every event:

```json theme={null}
"data": {
  "vault_session_id": "vs_8k2m4p9x",
  "user_id": "usr_3f9a1c",
  "origin": { "client_id": "client_staging_7h2k" }
}
```

`origin.client_id` names the OAuth client whose call made what the event is about: the vault session it minted, the purchase it started with `/buy`, the checkout authorization it created, or the wallet link it made. Each backend keeps the events that name its own client and returns a `2xx` for the rest. Any other status counts as a failed delivery, and Agentcard retries it.

`origin.client_id` is `null` when Agentcard has no client on record for the object, such as a card issued with `POST /api/v2/cards` or with an API key.

## Verify the signature

Each delivery carries an `AgentCard-Signature` header:

```
AgentCard-Signature: t=1757264400,v1=5257a869e7…
```

Take `t`, join it to the raw request body with a dot, compute HMAC-SHA256 with your endpoint's secret, and compare it to `v1` in constant time. Reject timestamps older than a few minutes to block replays. Verify against the raw bytes, never re-serialized JSON.

```javascript Node theme={null}
const [t, v1] = header.split(",").map((p) => p.split("=")[1]);
const expected = crypto
  .createHmac("sha256", process.env.AGENTCARD_WEBHOOK_SECRET)
  .update(`${t}.${rawBody}`)
  .digest("hex");
const valid = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
```

```python Python theme={null}
import hmac, hashlib, os

t, v1 = (part.split("=", 1)[1] for part in header.split(","))
expected = hmac.new(
    os.environ["AGENTCARD_WEBHOOK_SECRET"].encode(),
    f"{t}.{raw_body}".encode(),
    hashlib.sha256,
).hexdigest()
valid = hmac.compare_digest(expected, v1)
```

A legacy `X-AgentCard-Signature: sha256=…` header signs the body alone. New integrations should use `AgentCard-Signature`.

## Delivery and retries

Return a `2xx` quickly and do slow work afterwards. A slow handler looks like a failure. Failed deliveries retry up to five times: immediately, then after 1 minute, 5 minutes, 30 minutes, and 1 hour. Recent deliveries with payloads and response codes are on [List recent deliveries](https://docs.agentcard.com/api-reference/webhook-endpoints/deliveries.md) and in the dashboard.

## Develop locally

Expose your local server with a tunnel, then create a sandbox endpoint for the tunnel's URL with [Create a webhook endpoint](https://docs.agentcard.com/api-reference/webhook-endpoints/create.md). Every sandbox event reaches your machine, signed exactly like production. Delete the endpoint with [Delete a webhook endpoint](https://docs.agentcard.com/api-reference/webhook-endpoints/delete.md) when you are done.

## Sandbox

Sandbox events deliver exactly like production, with `livemode: false`. Endpoints are scoped to one mode: if your sandbox integration completes actions but nothing arrives, check that the endpoint was created with a sandbox token.

## Events by object

> [card] [Connections](https://docs.agentcard.com/webhooks/connections/overview.md)
>
> `connection.created`, `approval.requested`

> [card] [Vault](https://docs.agentcard.com/webhooks/vault/overview.md)
>
> `vault.session_linked`, `vault.card_stored`

> [card] [Checkout authorizations](https://docs.agentcard.com/webhooks/checkout-authorizations/overview.md)
>
> approved, submitted, declined, expired, amount\_mismatch

> [card] [Orders](https://docs.agentcard.com/webhooks/orders/overview.md)
>
> `order.placed`, `order.confirmed`, `order.failed`

> [card] [Cards and transactions](https://docs.agentcard.com/webhooks/cards/overview.md)
>
> `card.*`, `transaction.*`, `balance.low`

> [card] [Identity verification](https://docs.agentcard.com/webhooks/identity-verification/overview.md)
>
> `identity.verification.updated`

> [card] [Rewards and merchants](https://docs.agentcard.com/webhooks/rewards/overview.md)
>
> `reward.*`, `merchant.connected`

> [card] [Company wallet](https://docs.agentcard.com/webhooks/company-wallet/overview.md)
>
> `cardholder.*`, `card_flow.*`, `transfer.*`, `recovery.*`, `wallet.*`


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