# Webhooks reference (https://inference.net/docs/api/async/webhooks-reference)

Payloads, headers, delivery rules, and REST management endpoints for
asynchronous inference webhooks. For a step-by-step setup, see
[Webhooks](/docs/api/async/webhooks/).

## Dashboard management

Manage webhooks in [**Settings → Webhooks**](/dashboard/settings/webhooks/):

1. Create a webhook with a name and HTTPS URL.
2. Send a test event, disable or enable, or delete a webhook, and see its
   recent invocation stats.
3. Copy the webhook identifier to use in generation requests.

## Management API

You can manage webhooks with the REST API instead of the dashboard. Use it to
register a webhook from a deploy script or send a test delivery from CI.

### Authentication

Send your Inference.net API key in the `Authorization` header:

```bash
Authorization: Bearer $INFERENCE_API_KEY
```

Webhooks belong to the team that owns the API key:

- To list or get webhooks, the key needs `read` access to at least one project
  in the team.
- To create, update, delete, or test webhooks, the key must be a credit-billing
  API key with both `read` and `write` access within the team (each on at least
  one project in the team, not necessarily the same project), and the user who
  created the key must be a team owner or admin.
  [Inference Pass plan keys](/docs/api-keys/#plan-keys) cannot call webhook
  write or test routes and return `403` (`plan_route_not_supported`).

With **Zero Data Retention (ZDR)** on, disabling or deleting a webhook while it
has pending deliveries purges those results undelivered. See
[With Zero Data Retention](#with-zero-data-retention) and
[Data retention](/docs/data-retention/).

### Base URL

```text
https://relay.inference.net/api/rest
```

### The webhook object

```json
{
  "id": "0c6f6a1e-6c1b-4a0e-9a53-2f1f4d0e8b7a",
  "name": "Production receiver",
  "identifier": "AhALzdz8S",
  "teamId": "team_123",
  "url": "https://example.com/webhooks/inference",
  "isDisabled": false,
  "createdAt": "2026-01-03T06:46:22.838Z",
  "updatedAt": "2026-01-03T06:46:22.838Z"
}
```

| Field        | Description                                                                                                          |
| ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `id`         | Webhook ID. Use it in the URL path of the management requests below.                                                 |
| `identifier` | Webhook identifier. Send it as `metadata.webhook_id` on generations. Deliveries send it in `X-Inference-Webhook-ID`. |
| `name`       | Name you gave the webhook, or `null`.                                                                                |
| `url`        | HTTPS URL that receives deliveries.                                                                                  |
| `isDisabled` | `true` when deliveries are paused.                                                                                   |

<Callout tone="warning">

Keep the `identifier` private. Your endpoint uses it to verify that a delivery
comes from Inference.net.

</Callout>

### Create a webhook

`POST /webhooks`

| Body field | Type   | Required | Description                        |
| ---------- | ------ | -------- | ---------------------------------- |
| `url`      | string | Yes      | Public HTTPS URL of your endpoint. |
| `name`     | string | No       | Name to show in the dashboard.     |

```bash
curl https://relay.inference.net/api/rest/webhooks \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production receiver",
    "url": "https://example.com/webhooks/inference"
  }'
```

The response is `{ "webhook": { ... } }`. The URL must use HTTPS and point to a
public host. Other URLs fail with `400`.

### List webhooks

`GET /webhooks`

| Query parameter | Type    | Default | Description                 |
| --------------- | ------- | ------- | --------------------------- |
| `limit`         | integer | `50`    | Page size, from 1 to 100.   |
| `offset`        | integer | `0`     | Number of webhooks to skip. |

```bash
curl "https://relay.inference.net/api/rest/webhooks?limit=50&offset=0" \
  -H "Authorization: Bearer $INFERENCE_API_KEY"
```

The response is `{ "webhooks": [ ... ], "total": 1 }`. `total` is the number of
webhooks in the team.

### Get a webhook

`GET /webhooks/{webhookId}`

```bash
curl https://relay.inference.net/api/rest/webhooks/$WEBHOOK_ID \
  -H "Authorization: Bearer $INFERENCE_API_KEY"
```

The response is `{ "webhook": { ... } }`.

### Update a webhook

`PATCH /webhooks/{webhookId}`

Send only the fields to change: `name`, `url`, or `isDisabled`.

```bash
curl -X PATCH https://relay.inference.net/api/rest/webhooks/$WEBHOOK_ID \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "isDisabled": true }'
```

The response is `{ "webhook": { ... } }`.

### Send a test delivery

`POST /webhooks/{webhookId}/test`

Sends one `POST` with sample data to the webhook URL, with the same headers as
a real delivery. Test IDs start with `test-`.

| Body field  | Type   | Default        | Description                                                                                                          |
| ----------- | ------ | -------------- | -------------------------------------------------------------------------------------------------------------------- |
| `eventType` | string | `webhook.test` | Sample event to send: `webhook.test`, `generation.completed`, `slow-group.completed`, or `async-embedding.completed`. |

```bash
curl -X POST https://relay.inference.net/api/rest/webhooks/$WEBHOOK_ID/test \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "eventType": "generation.completed" }'
```

The response is a [test result](#test-results).

### Test a URL

`POST /webhooks/test-url`

Sends one sample event to a URL without creating a webhook. Use it to check an
endpoint before you register it. The URL rules and required access are the same
as for [Create a webhook](#create-a-webhook). The `X-Inference-Webhook-ID`
header is always `test-webhook`. In the JSON payload, `generation.completed`
and `async-embedding.completed` include `webhookId: "test-webhook"`,
`webhook.test` includes `webhook_id: "test-webhook"`, and
`slow-group.completed` includes `groupId` with no webhook ID field.

| Body field  | Type   | Required | Description                                                                                                                       |
| ----------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `url`       | string | Yes      | Public HTTPS URL to test.                                                                                                         |
| `eventType` | string | No       | Sample event to send: `webhook.test` (default), `generation.completed`, `slow-group.completed`, or `async-embedding.completed`. |

```bash
curl -X POST https://relay.inference.net/api/rest/webhooks/test-url \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/webhooks/inference",
    "eventType": "generation.completed"
  }'
```

The response is a [test result](#test-results).

### Test results

Both test endpoints return what was sent and how your endpoint answered:

```json
{
  "success": true,
  "statusCode": 200,
  "latencyMs": 182,
  "redirectLocation": null,
  "responseBody": "{\"received\":true}",
  "responseBodyTruncated": false,
  "request": {
    "url": "https://example.com/webhooks/inference",
    "method": "POST",
    "headers": {
      "Content-Type": "application/json",
      "User-Agent": "Kuzco-Webhook/1.0",
      "X-Inference-Event": "generation.completed",
      "X-Inference-Webhook-ID": "test-webhook",
      "X-Inference-Delivery-Attempt": "1",
      "X-Inference-Generation-ID": "test-generation-1767225600000"
    },
    "body": "{\"event\":\"generation.completed\",\"webhookId\":\"test-webhook\",...}"
  }
}
```

| Field                   | Description                                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `success`               | `true` for a `2xx` response within 30 seconds.                                                                      |
| `statusCode`            | HTTP status your endpoint returned. `0` when no response arrived (DNS, connection, or timeout failure).             |
| `error`                 | Description of the failure. Only present when `success` is `false`.                                                 |
| `latencyMs`             | Time to the response, in milliseconds.                                                                              |
| `redirectLocation`      | `Location` of a `3xx` response, or `null`. Tests do not follow redirects, so a `3xx` is a failure.                  |
| `responseBody`          | First 2 KB of the response body, as text. `null` when no response arrived.                                          |
| `responseBodyTruncated` | `true` when the response body was longer than 2 KB.                                                                 |
| `request`               | The `url`, `method`, `headers`, and JSON `body` (as a string) that were sent.                                       |

Live deliveries follow only `307` and `308` redirects, so register the final
URL. A test is sent once, with no retries, and is not counted in the webhook's
invocation stats. Test events can come from different IP addresses than live
deliveries.

You can send 5 tests per minute per user and 20 per minute per team. Over that
limit, a test fails with `429`. See
[Test your endpoint](/docs/api/async/webhooks/#test-your-endpoint) for what a
test sends.

### Delete a webhook

`DELETE /webhooks/{webhookId}`

```bash
curl -X DELETE https://relay.inference.net/api/rest/webhooks/$WEBHOOK_ID \
  -H "Authorization: Bearer $INFERENCE_API_KEY"
```

The response is `{ "success": true }`. Generations that still name the deleted
identifier do not get deliveries. To pause deliveries instead, set `isDisabled`
to `true`. With ZDR on, pending results for a deleted or disabled webhook are
purged undelivered.

### Management API errors

Errors return a JSON body with `code` and `message`:

```json
{ "code": "NOT_FOUND", "message": "Webhook not found" }
```

| Status | Code                | Cause                                                                             |
| ------ | ------------------- | --------------------------------------------------------------------------------- |
| `400`  | `BAD_REQUEST`       | The body or query is not valid, for example a URL that is not public HTTPS.       |
| `401`  | `UNAUTHORIZED`      | The API key is missing or not valid.                                              |
| `403`  | `FORBIDDEN`         | The key does not have the required access, its user is not a team owner or admin, or you used an Inference Pass plan key on a write or test route (`plan_route_not_supported`). |
| `404`  | `NOT_FOUND`         | No webhook with this ID exists in the team.                                       |
| `429`  | `TOO_MANY_REQUESTS` | More than 5 tests per minute for the user, or 20 for the team.                    |

The [`inf webhook`](https://docs.inference.net/cli/webhook) CLI commands run
the same operations, for example `inf webhook list` and
`inf webhook test --webhook-id <id>`.

## Payload structures

### generation.completed

```json
{
  "event": "generation.completed",
  "timestamp": "ISO 8601 timestamp",
  "webhookId": "webhook identifier",
  "data": {
    "id": "generation ID",
    "state": "Success|Failed|Queued|In Progress",
    "stateMessage": "Human readable status",
    "request": { /* Original request or null */ },
    "response": { /* OpenAI format response or null */ },
    "model": "model ID",
    "createdAt": "ISO 8601 timestamp",
    "dispatchedAt": "ISO 8601 timestamp or null",
    "firstChunkAt": "ISO 8601 timestamp or null",
    "finishedAt": "ISO 8601 timestamp or null",
    "deadlineAt": "ISO 8601 timestamp or null",
    "usage": { /* Token usage */ },
    "error": { "status": 400, "type": "context_length_exceeded" }
  }
}
```

The generation ID is `data.id`. The `response` object is compatible with the
OpenAI SDK types.

`data.error` is set when a failed generation's cause is known, and `null`
otherwise. `error.status` is the HTTP status the request failed with and
`error.type` a short error code. A 4xx status other than 429 means the request
itself was rejected: it fails again if you resend it unchanged. A 429 or 5xx
status is temporary, so retrying the same request can succeed. Queued requests continue processing
after the submitting client disconnects; disconnecting does not cancel
asynchronous work. With Zero Data Retention on, `stateMessage` has no error
text, but `error` is still set.

### async-embedding.completed

```json
{
  "event": "async-embedding.completed",
  "timestamp": "ISO 8601 timestamp",
  "webhookId": "webhook identifier",
  "data": {
    "id": "generation ID",
    "state": "Success|Failed|Queued|In Progress",
    "stateMessage": "Human readable status",
    "request": { /* Original embeddings request or null */ },
    "response": { /* OpenAI format embeddings response or null */ },
    "model": "model ID",
    "createdAt": "ISO 8601 timestamp",
    "dispatchedAt": "ISO 8601 timestamp or null",
    "firstChunkAt": "ISO 8601 timestamp or null",
    "finishedAt": "ISO 8601 timestamp or null",
    "deadlineAt": "ISO 8601 timestamp or null",
    "usage": { /* Token usage */ },
    "error": null
  }
}
```

### slow-group.completed

```json
{
  "event": "slow-group.completed",
  "timestamp": "ISO 8601 timestamp",
  "groupId": "group ID",
  "data": {
    "groupSize": 2,
    "status": "completed|failed",
    "generations": [
      {
        "id": "generation ID",
        "state": "Success|Failed|Queued|In Progress",
        "stateMessage": "Human readable status",
        "request": { /* Original request or null */ },
        "response": { /* OpenAI format response or null */ },
        "model": "model ID",
        "createdAt": "ISO 8601 timestamp",
        "dispatchedAt": "ISO 8601 timestamp or null",
        "firstChunkAt": "ISO 8601 timestamp or null",
        "finishedAt": "ISO 8601 timestamp or null",
        "deadlineAt": "ISO 8601 timestamp or null",
        "usage": { /* Token usage */ },
        "error": null
      }
    ]
  }
}
```

`data.status` is `failed` when the group could not finish: processing failed,
or the group passed its 72-hour completion window. Check each entry's `state`
in `generations` to see which requests finished.

### Dashboard test events

A [test](/docs/api/async/webhooks/#test-your-endpoint) from
[**Settings → Webhooks**](/dashboard/settings/webhooks/) sends a sample payload
for the event type you choose (`generation.completed`, `slow-group.completed`, or
`async-embedding.completed`). The payload has the same
shape and headers as a real delivery, with `test-model` as the model (`test-embedding-model` for
`async-embedding.completed`) and IDs that
start with `test-` (for example `test-generation-1767225600000`), so your
endpoint can tell a test from a real event.

## Headers

| Header                         | Description                       | Example                                                                        |
| ------------------------------ | --------------------------------- | ------------------------------------------------------------------------------ |
| `X-Inference-Event`            | Event type                        | `generation.completed`, `async-embedding.completed`, or `slow-group.completed` |
| `X-Inference-Webhook-ID`       | Webhook identifier                | `AhALzdz8S`                                                                    |
| `X-Inference-Generation-ID`    | Generation ID (generation events) | `XBKcs7F1s2oJ_AHiLMbF4`                                                        |
| `X-Inference-Embedding-ID`     | Generation ID (embedding events)  | `XBKcs7F1s2oJ_AHiLMbF4`                                                        |
| `X-Inference-Group-ID`         | Group ID (group events)           | `GRP_XYZ123`                                                                   |
| `X-Inference-Delivery-Attempt` | Delivery attempt, starting at 1   | `1`                                                                            |
| `User-Agent`                   | Inference.net webhook agent       | `Kuzco-Webhook/1.0`                                                            |
| `Content-Type`                 | Always `application/json`         | `application/json`                                                             |

## Use a webhook in a generation

Include the webhook identifier in the request metadata:

<CodeTabs>

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.inference.net/v1/slow",
  apiKey: process.env.INFERENCE_API_KEY,
});

const response = await client.chat.completions.create({
  model: "kimi-k3-fast",
  messages: [{ role: "user", content: "Hello!" }],
  // @ts-expect-error metadata is not in the OpenAI SDK types
  metadata: { webhook_id: "YOUR_WEBHOOK_IDENTIFIER" },
});
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.inference.net/v1/slow",
    api_key=os.environ["INFERENCE_API_KEY"],
)

response = client.chat.completions.create(
    model="kimi-k3-fast",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_body={"metadata": {"webhook_id": "YOUR_WEBHOOK_IDENTIFIER"}},
)
```

```bash
curl https://api.inference.net/v1/slow/chat/completions \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3-fast",
    "messages": [{"role": "user", "content": "Hello!"}],
    "metadata": {"webhook_id": "YOUR_WEBHOOK_IDENTIFIER"}
  }'
```

</CodeTabs>

For groups, pass `webhook_id` at the top level of the request body. See
[Group API](/docs/api/async/group/#use-webhooks).

If `webhook_id` does not match a webhook in your team, the request fails with
`400` and error type `WebhookNotFound`.

### With Zero Data Retention

With the **Zero Data Retention (ZDR)** team setting on:

- A `/v1/slow` request must set `metadata.webhook_id`, or it fails with `400`.
- A disabled webhook fails with `400` and error type `WebhookDisabled`.
- The result is delivered only through the webhook. Its request and response
  content is purged once delivery succeeds, its 24 attempts (about 3 days) run
  out, or the webhook can no longer be delivered (deleted, disabled, or its URL
  is not allowed).

See [Data retention](/docs/data-retention/).

## Minimal handlers

<CodeTabs>

```typescript
app.post("/webhook", express.json(), (req, res) => {
  res.status(200).json({ received: true });

  if (req.body.event === "generation.completed") {
    setImmediate(() => {
      console.log("Generation completed:", req.body.data.id);
      // Your processing logic here
    });
  } else if (req.body.event === "async-embedding.completed") {
    setImmediate(() => {
      console.log("Embedding completed:", req.body.data.id);
      console.log("Number of embeddings:", req.body.data.response.data.length);
    });
  } else if (req.body.event === "slow-group.completed") {
    setImmediate(() => {
      console.log("Group completed:", req.body.groupId);
      console.log("Group size:", req.body.data.groupSize);
      req.body.data.generations.forEach((gen: any) => {
        console.log(`Generation ${gen.id}: ${gen.state}`);
      });
    });
  }
});
```

```python
@app.post("/webhook")
async def handle_webhook(payload: dict, background_tasks: BackgroundTasks):
    background_tasks.add_task(process_webhook, payload)
    return {"received": True}

def process_webhook(payload):
    if payload["event"] == "generation.completed":
        print(f"Processing generation {payload['data']['id']}")
        # Your processing logic here
    elif payload["event"] == "async-embedding.completed":
        print(f"Processing embedding {payload['data']['id']}")
        print(f"Number of embeddings: {len(payload['data']['response']['data'])}")
    elif payload["event"] == "slow-group.completed":
        print(f"Processing group {payload['groupId']}")
        print(f"Group size: {payload['data']['groupSize']}")
        for gen in payload["data"]["generations"]:
            print(f"Generation {gen['id']}: {gen['state']}")
```

</CodeTabs>

## Retries and delivery

Each delivery attempt is one `POST` to your URL, with no `OPTIONS` preflight.
Your response body is ignored. Payload size scales with the generation; there is
no fixed limit.

### Attempt outcomes

| Outcome                                                         | Result                    |
| --------------------------------------------------------------- | ------------------------- |
| `2xx` response within 30 seconds                                | Delivered; no more tries  |
| `307` or `308` redirect                                         | Followed, up to 4 hops    |
| Any other status, including `301`, `302`, and `303`             | Failed; retried           |
| No response within 30 seconds                                   | Failed; retried           |
| Connection error (DNS, TLS, refused, reset)                     | Failed; retried           |
| URL not allowed (private address, over 4 redirects, bad target) | Not delivered; no retries |
| Webhook disabled or deleted                                     | Not delivered; no retries |

A `307` or `308` redirect re-sends the same `POST` body to the new location.
The 30-second timeout covers the whole redirect chain. A redirect to a different
origin (scheme, host, or port) keeps only `Content-Type`, `Accept`, and
`User-Agent`: the `X-Inference-*` headers are not sent to the new origin.
There, deduplicate on `data.id` or `groupId` in the payload, and verify
generation events with their `webhookId` field; group events carry no webhook
ID in the payload, so don't redirect a webhook that receives them across
origins.

### Retry schedule

An event gets at most 24 attempts, the first one included. The waits are the
configured values; each varies by up to 20% either way. The times are nominal:
they leave out that jitter, the time your endpoint takes to answer, and
queueing, which can make a wait longer.

| Attempt  | Wait before it | Time since the first attempt |
| -------- | -------------- | ---------------------------- |
| 1        | None           | 0                            |
| 2        | 5 seconds      | 5 seconds                    |
| 3        | 30 seconds     | 35 seconds                   |
| 4        | 2 minutes      | 2 minutes 35 seconds         |
| 5        | 10 minutes     | 12 minutes 35 seconds        |
| 6        | 30 minutes     | 42 minutes 35 seconds        |
| 7        | 1 hour         | About 1 hour 43 minutes      |
| 8        | 2 hours        | About 3 hours 43 minutes     |
| 9        | 4 hours        | About 7 hours 43 minutes     |
| 10 to 23 | 4 hours each   | 4 hours more per attempt     |
| 24       | 4 hours        | About 67 hours 43 minutes    |

If attempt 24 fails, the event is dropped, nominally about 68 hours (3 days)
after the first attempt. With jitter alone, that is between about 54 and 81
hours; queueing can make it later. A dropped event's request and response
content is deleted, so its result cannot be fetched from the
[generation status endpoint](/docs/api/async/overview/#retrieve-the-result). See
[Data retention](/docs/data-retention/#asynchronous-results-are-kept-until-delivery-finishes).

When your endpoint answers `2xx` again after failing, the events still waiting
in this schedule usually start to be resent within minutes, a few at a time,
instead of at their next scheduled attempt. With Zero Data Retention on,
`generation.completed` and `async-embedding.completed` events keep this
schedule.

A request sent with a `metadata.completion_window` of 1 hour or less retries
faster inside that window: each wait is half the time left to the deadline, at
least 1/16 of the window, and never longer than the wait above. After the
deadline, the schedule above resumes at the current attempt. See the
[worked example](/docs/api/async/overview/#worked-example-a-4-minute-window).

### Delivery guarantee

Retryable failures follow an at-least-once policy: an event is retried until a
`2xx` or until attempt 24. Events that are not delivered and not retried (see
[Attempt outcomes](#attempt-outcomes)) may never reach your endpoint. After a
delivery succeeds, later redeliveries of the same event are not sent, but your
endpoint can still get an event twice: for example, when it processed a request
but answered after the 30-second timeout. Deduplicate on:

- `X-Inference-Generation-ID` (the same value as `data.id`) for
  `generation.completed` and `async-embedding.completed` events.
- `X-Inference-Group-ID` (the same value as `groupId`) for
  `slow-group.completed` events.

`X-Inference-Delivery-Attempt` is the attempt number, starting at 1. The
payload `timestamp` is the same on every attempt for an event.

### Content purge with Zero Data Retention

With the **Zero Data Retention (ZDR)** team setting on, the request and response
content of a `generation.completed` or `async-embedding.completed` event is
purged when the event is delivered, dropped after attempt 24, or not delivered
because the URL is not allowed or the webhook is disabled or deleted. A dropped
event's result cannot be fetched. A group submitted with ZDR on is delivered
only in its `slow-group.completed` event, and its requests, responses, and
input are purged on the same terms. For a group already in progress when ZDR is
turned on, each request's request content is purged when it finishes. For
every team, ZDR on or off, a finished request's content is deleted once its
delivery finishes. See
[Retention and groups](/docs/data-retention/#retention-and-groups) and
[Data retention](/docs/data-retention/#asynchronous-results-are-kept-until-delivery-finishes).

### Recommendations

- Return a `2xx` as soon as you receive the event, well within 30 seconds, and
  process it asynchronously.
- Make processing idempotent with the IDs above.
- Don't redirect the webhook URL. If you must, use `307` or `308`.

## Checklist

- [ ] Respond with 200 OK immediately
- [ ] Process webhook data asynchronously
- [ ] Make processing idempotent with `data.id` (generation events) or `groupId` (group events)
- [ ] Validate the webhook source with headers
- [ ] Handle errors gracefully
- [ ] Monitor webhook processing
- [ ] Use an HTTPS endpoint
- [ ] Set up error logging
- [ ] Test the webhook from the dashboard
- [ ] Handle timeouts
- [ ] Handle both individual and group completions

## Common issues

| Issue                  | Solution                                                                         |
| ---------------------- | -------------------------------------------------------------------------------- |
| Not receiving webhooks | Check the webhook is not disabled in the dashboard, test connectivity, check URL |
| Duplicate webhooks     | Make processing idempotent, return 200 OK                                        |
| Webhooks timing out    | Respond immediately, process asynchronously                                      |
| Invalid payload        | Validate against the documented schema                                           |
| Test webhook fails     | Check the endpoint is publicly reachable and returns 200 OK                      |

## Support

Email [support@inference.net](mailto:support@inference.net).