# An API key expires soon

> For AI agents: the index of these docs is at https://referalli.com/docs/llms.txt (every page it lists has a Markdown version like this one).

## An API key expires soon

**`WEBHOOK api_key.expiring`** — An API key expires soon

Sent 30, 7 and 1 days before an API key with an expiry stops working (once each; a key first seen inside a window gets only that notice). Rotate it with `POST /v1/api-keys/{id}/rotate` or extend it with `PATCH /v1/api-keys/{id}`. A key rotated out (in its grace period) gets no notice.

POSTed to every active webhook endpoint subscribed to `api_key.expiring` (or `*`), signed the Standard Webhooks way. Answer any 2xx within 15 seconds; anything else is retried with backoff for 3 days.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `webhook-id` | header | string | yes | The delivery id; the same on every retry and replay. Deduplicate on it. |
| `webhook-timestamp` | header | integer | yes | When this attempt was signed, in unix seconds. Reject it when more than 5 minutes from your clock. |
| `webhook-signature` | header | string | yes | `v1,` plus the base64 HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed with the base64-decoded secret after `whsec_`. During a rotation, two signatures separated by a space. |
| `x-referalli-topic` | header | string | yes | The event topic, as in the body. The legacy header names from before the rename are also sent, with identical values, for existing integrations. |

### Payload (`application/json`)

An API key expires soon: the `api_key.expiring` delivery body.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The event id (`evt_…`); the same event delivered to several endpoints has the same id. |
| `topic` | string | yes |  |
| `orgId` | string | yes |  |
| `livemode` | boolean | yes | false for events from test mode. |
| `createdAt` | string | yes |  |
| `data` | object | yes | `data` of a `api_key.expiring` event: Sent 30, 7 and 1 days before an API key with an expiry stops working (once each; a key first seen inside a window gets only that notice). Rotate it with `POST /v1/api-keys/{id}/rotate` or extend it with `PATCH /v1/api-keys/{id}`. A key rotated out (in its grace period) gets no notice. |
| `data.keyId` | string | yes |  |
| `data.name` | string | yes |  |
| `data.prefix` | string | yes | The first 12 characters of the secret, as listed. |
| `data.owner` | string | yes |  |
| `data.expiresAt` | string | yes |  |
| `data.daysBefore` | number | yes | Which notice this is. |

```json
{
  "id": "string",
  "topic": "string",
  "orgId": "string",
  "livemode": true,
  "createdAt": "2024-01-01T00:00:00Z",
  "data": {
    "keyId": "string",
    "name": "string",
    "prefix": "string",
    "owner": "string",
    "expiresAt": "2024-01-01T00:00:00Z",
    "daysBefore": 0
  }
}
```

### Responses

**200** — Received. Any 2xx acknowledges the delivery.

---

## For AI agents

- This page for a human reader: https://referalli.com/docs/ref-webhookapikeyexpiring
- The whole space as one Markdown file: https://referalli.com/docs/llms-full.txt
- Live search + fetch over MCP: https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/mcp
  - Install (Claude CLI): `claude mcp add referalli --transport http https://referalli.com/docs/_api/public/orgs/07f432f4-34b9-46a7-aaad-c0e395d2e4f9/spaces/2bf4f614-3630-4fbf-85f9-5ecafa6b7d97/mcp`

This Markdown is the same content the page renders — safe to quote and to ground answers in.
