# Webhooks

> The account's events feed and the webhook endpoints they are sent to, signed as Standard Webhooks; the low-balance alert.


## The account's events, oldest first

<a id="events.index"></a>`events.index`

`GET /events`

Scope: `webhooks`

What happened to the account in the last 30 days: generations and side actions that ended, a low balance and tests. Send the last id you saw as after to get only newer ones. Events appear here 2 seconds after they happen, so none is ever skipped. The same objects are sent to your webhook endpoints.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `after` | query | string | No | The id of the last event you saw. An unknown one, or one older than 30 days, answers 422 (fields.after). |
| `types` | query | array of EventType | No | Only these event types, separated by commas. |
| `limit` | query | integer | No | Items per page. |

### Responses

- `200` The next events, oldest first. ([`EventList`](https://imgsearch.com/developers/reference/schemas.md#EventList))
- `422` A bad after, types or limit. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# The account's events, oldest first. Set EVENT_ID to the last id you saw to get only newer ones.
# Needs IMGSEARCH_API_KEY.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/events?limit=20${EVENT_ID:+&after=$EVENT_ID}" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# The account's events, oldest first. Set EVENT_ID to the last id you saw to get only newer ones.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

params = {"limit": 20}
if os.environ.get("EVENT_ID"):
    params["after"] = os.environ["EVENT_ID"]
r = httpx.get(f"{base}/events", headers=headers, params=params, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// The account's events, oldest first. Set EVENT_ID to the last id you saw to get only newer ones.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/events?limit=20${process.env.EVENT_ID ? `&after=${process.env.EVENT_ID}` : ""}`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "data": [
        {
            "id": "evt_01m6x88gs30v5mcxpyk61vcvgs",
            "object": "event",
            "type": "balance.low",
            "created_at": "2026-11-08T09:36:32Z",
            "data": {
                "available_usd": 0.396,
                "below_usd": 0.5
            }
        },
        {
            "id": "evt_01m8bkxned2se4dgw1mmapf82x",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:23Z",
            "data": {
                "id": "01m8bkxn8gmyyqj31x765qt22q",
                "kind": "image",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.01,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "image/png"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxnmxk9reytbyrenthm35",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:23Z",
            "data": {
                "id": "01m8bkxnerhxb8f1db4tja55jq",
                "kind": "audio",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.005,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "audio/mpeg"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxpxmeprfj3t4rn2b15qf",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:25Z",
            "data": {
                "id": "01m8bkxnmvbtztw64v4jc0b3jb",
                "kind": "3d",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.1,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "model/gltf-binary"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxqyy11v580t796d0epp4",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:26Z",
            "data": {
                "id": "01m8bkxncmn3vg8hfznkpy1f65",
                "kind": "music",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.02,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "audio/mpeg"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxr91w5tnycn71r2x0p7h",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:26Z",
            "data": {
                "id": "01m8bkxnatzr40rjsk4hk318eb",
                "kind": "video",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.027,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "video/mp4"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxsjnddcvd0y37r87959d",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:27Z",
            "data": {
                "id": "01m8bkxs9212pmc6h2hzwnys3s",
                "kind": "image",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.01,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "image/png"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bkxt6hw39tgcyhz1xrkf6k",
            "object": "event",
            "type": "generation.failed",
            "created_at": "2026-11-26T09:45:28Z",
            "data": {
                "id": "01m8bkxt07eds5vxbad257azj0",
                "kind": "image",
                "model": "fal-ai/seedvr/upscale/image",
                "status": "failed",
                "charged_usd": 0,
                "outputs": [],
                "error": {
                    "code": "generation_failed",
                    "message": "The model is overloaded or did not respond. Please try again in a moment. Your $0.006 was refunded.",
                    "retryable": true
                }
            }
        },
        {
            "id": "evt_01m8bkxtm2yqh8ckyyaqb9j6kn",
            "object": "event",
            "type": "generation.export.succeeded",
            "created_at": "2026-11-26T09:45:28Z",
            "data": {
                "id": "01m8bkxnmvbtztw64v4jc0b3jb",
                "kind": "3d",
                "export": {
                    "key": "fbx-asis",
                    "format": "fbx",
                    "height_m": null,
                    "status": "succeeded",
                    "error": null
                }
            }
        },
        {
            "id": "evt_01m8bkxv4pr6hj809brgeg047j",
            "object": "event",
            "type": "generation.soundtrack.succeeded",
            "created_at": "2026-11-26T09:45:29Z",
            "data": {
                "id": "01m8bkxnatzr40rjsk4hk318eb",
                "kind": "video",
                "soundtrack": {
                    "n": 0,
                    "music_id": "01m8bkxncmn3vg8hfznkpy1f65",
                    "voice_id": null,
                    "status": "succeeded",
                    "error": null
                }
            }
        },
        {
            "id": "evt_01m8bkxvc2kvwy78tekksdcjet",
            "object": "event",
            "type": "generation.voiceover_video.succeeded",
            "created_at": "2026-11-26T09:45:29Z",
            "data": {
                "id": "01m8bkxnerhxb8f1db4tja55jq",
                "kind": "audio",
                "voiceover_video": {
                    "video_id": "01m8bkxnatzr40rjsk4hk318eb",
                    "n": 0,
                    "status": "succeeded",
                    "error": null
                }
            }
        },
        {
            "id": "evt_01m8bkxvfys8dvw40v83ksm2pd",
            "object": "event",
            "type": "generation.canceled",
            "created_at": "2026-11-26T09:45:29Z",
            "data": {
                "id": "01m8bkxvdyfespxd9sbk178hkr",
                "kind": "image",
                "model": "local/echo",
                "status": "canceled",
                "charged_usd": 0,
                "outputs": [],
                "error": {
                    "code": "canceled",
                    "message": "Canceled before it started. Your $0.01 was refunded.",
                    "retryable": false
                }
            }
        },
        {
            "id": "evt_01m8bkxvtehe9a0yhszfk8p3cf",
            "object": "event",
            "type": "webhook.test",
            "created_at": "2026-11-26T09:45:30Z",
            "data": {
                "endpoint_id": "whk_01m8bkxvnqcae37g434j6g9kxg",
                "message": "This is a test event from ImgSearch."
            }
        },
        {
            "id": "evt_01m8bky58xfdsf4nj393hhf8h4",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:39Z",
            "data": {
                "id": "01m8bkxtwgssxsn1ed6e65jnza",
                "kind": "image",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.01,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "image/png"
                    }
                ],
                "error": null
            }
        },
        {
            "id": "evt_01m8bky5v410d4vstcm009c211",
            "object": "event",
            "type": "generation.export.succeeded",
            "created_at": "2026-11-26T09:45:40Z",
            "data": {
                "id": "01m8bkxnmvbtztw64v4jc0b3jb",
                "kind": "3d",
                "export": {
                    "key": "usdz-1.20",
                    "format": "usdz",
                    "height_m": 1.2,
                    "status": "succeeded",
                    "error": null
                }
            }
        },
        {
            "id": "evt_01m8bky5wqsgb2tyr2e489ew6w",
            "object": "event",
            "type": "generation.ar.succeeded",
            "created_at": "2026-11-26T09:45:40Z",
            "data": {
                "id": "01m8bkxnmvbtztw64v4jc0b3jb",
                "kind": "3d",
                "ar": {
                    "height_m": 1.2,
                    "status": "succeeded",
                    "error": null
                }
            }
        },
        {
            "id": "evt_01m8bky9bp4pk2hw2mh9yavtny",
            "object": "event",
            "type": "generation.succeeded",
            "created_at": "2026-11-26T09:45:44Z",
            "data": {
                "id": "01m8bky93c0jbbax10h5qnjj0m",
                "kind": "image",
                "model": "local/echo",
                "status": "succeeded",
                "charged_usd": 0.01,
                "outputs": [
                    {
                        "n": 0,
                        "mime": "image/png"
                    }
                ],
                "error": null
            }
        }
    ],
    "has_more": false
}
```

## The low-balance alert

<a id="events.settings"></a>`events.settings`

`GET /events/settings`

Scope: `webhooks`

### Responses

- `200` The settings. ([`EventSettings`](https://imgsearch.com/developers/reference/schemas.md#EventSettings))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# The low-balance alert.
# Needs IMGSEARCH_API_KEY.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/events/settings" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# The low-balance alert.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/events/settings", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// The low-balance alert.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/events/settings`, { headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` } });
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "event_settings",
    "balance_low_below_usd": 0.5
}
```

## Set or turn off the low-balance alert

<a id="events.settings.update"></a>`events.settings.update`

`PATCH /events/settings`

Scope: `webhooks`

balance.low is sent once when your spendable AI balance falls below balance_low_below_usd, and again only after it was back at or above it and a day has passed. null turns it off.

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `balance_low_below_usd` | number or null | Yes | In US dollars, with at most three decimals. At least 0.001, At most 100. |

### Responses

- `200` The settings. ([`EventSettings`](https://imgsearch.com/developers/reference/schemas.md#EventSettings))
- `422` Not a number from 1 to 100,000 or null. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Sends balance.low when the spendable AI balance falls below $0.50.
# Needs IMGSEARCH_API_KEY.
curl -sS -X PATCH \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/events/settings" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "balance_low_below_usd": 0.5
}'
```

**Python**

```python
# Sends balance.low when the spendable AI balance falls below $0.50.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.patch(f"{base}/events/settings", headers=headers, json={"balance_low_below_usd": 0.5}, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Sends balance.low when the spendable AI balance falls below $0.50.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/events/settings`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ balance_low_below_usd: 0.5 }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "event_settings",
    "balance_low_below_usd": 0.5
}
```

## Your webhook endpoints

<a id="webhooks.index"></a>`webhooks.index`

`GET /webhooks`

Scope: `webhooks`

At most five; never with their secrets.

### Responses

- `200` Every endpoint of the account. ([`List`](https://imgsearch.com/developers/reference/schemas.md#List))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Your webhook endpoints, never with their secrets.
# Needs IMGSEARCH_API_KEY.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Your webhook endpoints, never with their secrets.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/webhooks", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Your webhook endpoints, never with their secrets.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks`, { headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` } });
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "data": [
        {
            "object": "webhook_endpoint",
            "id": "whk_01m8bkycnycaps4yqqk7b4vsnx",
            "url": "https://example.com/imgsearch/webhooks",
            "description": "Every generation result",
            "event_types": [
                "generation.succeeded",
                "generation.failed",
                "generation.canceled"
            ],
            "status": "enabled",
            "disabled_reason": null,
            "failing_since": null,
            "last_success_at": null,
            "disabled_at": null,
            "secret_rotation_ends_at": null,
            "created_at": "2026-11-26T09:45:47Z",
            "updated_at": "2026-11-26T09:45:47Z"
        }
    ],
    "has_more": false,
    "next_cursor": null
}
```

## Add an endpoint

<a id="webhooks.store"></a>`webhooks.store`

`POST /webhooks`

Scope: `webhooks`

An https address on port 443 of your own server; its host must resolve to public addresses only, and it is checked again before every delivery. The answer carries the signing secret, the only time it is shown. At most five endpoints (409 conflict, details.limit), 30 changes an hour.

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | Yes | At most 2048 characters. |
| `description` | string or null | No | At most 200 characters. |
| `event_types` | array of SubscribableEventType or null | No | The types it receives; null or left out for every type. At least 1 items. |

### Responses

- `201` The endpoint and its signing secret. ([`WebhookEndpointWithSecret`](https://imgsearch.com/developers/reference/schemas.md#WebhookEndpointWithSecret))
- `409` The account has five endpoints already. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `422` A refused address (fields.url says why) or event type. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 changes in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Adds an endpoint. The answer's secret is shown only this once: store it.
# Needs IMGSEARCH_API_KEY and WEBHOOK_URL.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<EOF
{
  "url": "$WEBHOOK_URL",
  "description": "Generation results",
  "event_types": [
    "generation.succeeded",
    "generation.failed"
  ]
}
EOF
```

**Python**

```python
# Adds an endpoint. The answer's secret is shown only this once: store it.
# Needs IMGSEARCH_API_KEY and WEBHOOK_URL.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/webhooks",
    headers=headers,
    json={
        "url": os.environ["WEBHOOK_URL"],
        "description": "Generation results",
        "event_types": ["generation.succeeded", "generation.failed"],
    },
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Adds an endpoint. The answer's secret is shown only this once: store it.
// Needs IMGSEARCH_API_KEY and WEBHOOK_URL.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: process.env.WEBHOOK_URL,
    description: "Generation results",
    event_types: ["generation.succeeded", "generation.failed"],
  }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 201**

```json
{
    "object": "webhook_endpoint",
    "id": "whk_01m8bkycnycaps4yqqk7b4vsnx",
    "url": "https://example.com/imgsearch/webhooks",
    "description": "Generation results",
    "event_types": [
        "generation.succeeded",
        "generation.failed"
    ],
    "status": "enabled",
    "disabled_reason": null,
    "failing_since": null,
    "last_success_at": null,
    "disabled_at": null,
    "secret_rotation_ends_at": null,
    "created_at": "2026-11-26T09:45:47Z",
    "updated_at": "2026-11-26T09:45:47Z",
    "secret": "whsec_EXAMPLEc2VjcmV0LXNob3duLW9uY2U="
}
```

## One endpoint

<a id="webhooks.show"></a>`webhooks.show`

`GET /webhooks/{id}`

Scope: `webhooks`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |

### Responses

- `200` The endpoint. ([`WebhookEndpoint`](https://imgsearch.com/developers/reference/schemas.md#WebhookEndpoint))
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# One endpoint.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# One endpoint.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/webhooks/{os.environ['WEBHOOK_ID']}", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// One endpoint.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "webhook_endpoint",
    "id": "whk_01m8bkycnycaps4yqqk7b4vsnx",
    "url": "https://example.com/imgsearch/webhooks",
    "description": "Generation results",
    "event_types": [
        "generation.succeeded",
        "generation.failed"
    ],
    "status": "enabled",
    "disabled_reason": null,
    "failing_since": null,
    "last_success_at": null,
    "disabled_at": null,
    "secret_rotation_ends_at": null,
    "created_at": "2026-11-26T09:45:47Z",
    "updated_at": "2026-11-26T09:45:47Z"
}
```

## Delete an endpoint and its delivery log

<a id="webhooks.destroy"></a>`webhooks.destroy`

`DELETE /webhooks/{id}`

Scope: `webhooks`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |

### Responses

- `204` Deleted.
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 changes in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Deletes an endpoint and its delivery log. 204 with no body.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS -X DELETE \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -w '%{http_code}\n'
```

**Python**

```python
# Deletes an endpoint and its delivery log. 204 with no body.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.delete(f"{base}/webhooks/{os.environ['WEBHOOK_ID']}", headers=headers, timeout=60)
print(r.status_code)
```

**JavaScript**

```js
// Deletes an endpoint and its delivery log. 204 with no body.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}`, {
  method: "DELETE",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
```

## Change an endpoint, or turn it off or on

<a id="webhooks.update"></a>`webhooks.update`

`PATCH /webhooks/{id}`

Scope: `webhooks`

A new url is checked as on create and starts the failure count again. enabled true turns on an endpoint you turned off or one turned off after 3 days of failures; nothing missed is resent by itself.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | No | At most 2048 characters. |
| `description` | string or null | No | At most 200 characters. |
| `event_types` | array of SubscribableEventType or null | No | At least 1 items. |
| `enabled` | boolean | No |  |

### Responses

- `200` The endpoint. ([`WebhookEndpoint`](https://imgsearch.com/developers/reference/schemas.md#WebhookEndpoint))
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `422` A refused address or event type. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 changes in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Changes what an endpoint receives.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS -X PATCH \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "Every generation result",
  "event_types": [
    "generation.succeeded",
    "generation.failed",
    "generation.canceled"
  ]
}'
```

**Python**

```python
# Changes what an endpoint receives.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.patch(
    f"{base}/webhooks/{os.environ['WEBHOOK_ID']}",
    headers=headers,
    json={
        "description": "Every generation result",
        "event_types": ["generation.succeeded", "generation.failed", "generation.canceled"],
    },
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Changes what an endpoint receives.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    description: "Every generation result",
    event_types: ["generation.succeeded", "generation.failed", "generation.canceled"],
  }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "webhook_endpoint",
    "id": "whk_01m8bkycnycaps4yqqk7b4vsnx",
    "url": "https://example.com/imgsearch/webhooks",
    "description": "Every generation result",
    "event_types": [
        "generation.succeeded",
        "generation.failed",
        "generation.canceled"
    ],
    "status": "enabled",
    "disabled_reason": null,
    "failing_since": null,
    "last_success_at": null,
    "disabled_at": null,
    "secret_rotation_ends_at": null,
    "created_at": "2026-11-26T09:45:47Z",
    "updated_at": "2026-11-26T09:45:47Z"
}
```

## Send a webhook.test event

<a id="webhooks.test"></a>`webhooks.test`

`POST /webhooks/{id}/test`

Scope: `webhooks`

To this endpoint only, also when it is turned off; one attempt. 30 manual actions an hour.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |

### Responses

- `202` The test event's delivery, on its way. ([`WebhookDelivery`](https://imgsearch.com/developers/reference/schemas.md#WebhookDelivery))
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 manual actions in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Sends a webhook.test event to this endpoint, one attempt.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID/test" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Sends a webhook.test event to this endpoint, one attempt.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(f"{base}/webhooks/{os.environ['WEBHOOK_ID']}/test", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Sends a webhook.test event to this endpoint, one attempt.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}/test`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 202**

```json
{
    "object": "webhook_delivery",
    "id": "evt_01m8bkydbq3z14kddmwg7fy822",
    "event_type": "webhook.test",
    "event_created_at": "2026-11-26T09:45:48Z",
    "status": "pending",
    "attempts": 0,
    "next_attempt_at": "2026-11-26T09:45:48Z",
    "last_attempt_at": null,
    "response": null
}
```

## A new signing secret

<a id="webhooks.rotate-secret"></a>`webhooks.rotate-secret`

`POST /webhooks/{id}/rotate-secret`

Scope: `webhooks`

The answer carries the new secret, shown this once. For 24 hours every delivery is signed with both, so you can switch over; a second rotation in that time drops the oldest at once.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |

### Responses

- `200` The endpoint and its new secret. ([`WebhookEndpointWithSecret`](https://imgsearch.com/developers/reference/schemas.md#WebhookEndpointWithSecret))
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 manual actions in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# A new signing secret, shown once; the old one also signs for 24 hours.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID/rotate-secret" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# A new signing secret, shown once; the old one also signs for 24 hours.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(f"{base}/webhooks/{os.environ['WEBHOOK_ID']}/rotate-secret", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// A new signing secret, shown once; the old one also signs for 24 hours.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}/rotate-secret`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "webhook_endpoint",
    "id": "whk_01m8bkycnycaps4yqqk7b4vsnx",
    "url": "https://example.com/imgsearch/webhooks",
    "description": "Every generation result",
    "event_types": [
        "generation.succeeded",
        "generation.failed",
        "generation.canceled"
    ],
    "status": "enabled",
    "disabled_reason": null,
    "failing_since": null,
    "last_success_at": "2026-11-26T09:45:48Z",
    "disabled_at": null,
    "secret_rotation_ends_at": "2026-11-27T09:45:48Z",
    "created_at": "2026-11-26T09:45:47Z",
    "updated_at": "2026-11-26T09:45:48Z",
    "secret": "whsec_EXAMPLEc2VjcmV0LXNob3duLW9uY2U="
}
```

## An endpoint's delivery log, newest first

<a id="webhooks.deliveries"></a>`webhooks.deliveries`

`GET /webhooks/{id}/deliveries`

Scope: `webhooks`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |
| `status` | query | string | No | One of: pending, delivered, failed. |
| `limit` | query | integer | No | Items per page. |
| `cursor` | query | string | No | The next_cursor of the previous page, as it came. It works only for the same list, filter and account. |

### Responses

- `200` One page of deliveries. ([`List`](https://imgsearch.com/developers/reference/schemas.md#List))
- `404` No such endpoint on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# An endpoint's delivery log, newest first.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID/deliveries?limit=10" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# An endpoint's delivery log, newest first.
# Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(
    f"{base}/webhooks/{os.environ['WEBHOOK_ID']}/deliveries",
    headers=headers,
    params={"limit": 10},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// An endpoint's delivery log, newest first.
// Needs IMGSEARCH_API_KEY and WEBHOOK_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}/deliveries?limit=10`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "data": [
        {
            "object": "webhook_delivery",
            "id": "evt_01m8bkydbq3z14kddmwg7fy822",
            "event_type": "webhook.test",
            "event_created_at": "2026-11-26T09:45:48Z",
            "status": "delivered",
            "attempts": 1,
            "next_attempt_at": null,
            "last_attempt_at": "2026-11-26T09:45:48Z",
            "response": {
                "ms": 1,
                "body": "ok",
                "error": null,
                "status": 200
            }
        }
    ],
    "has_more": false,
    "next_cursor": null
}
```

## Send an event to this endpoint again

<a id="webhooks.redeliver"></a>`webhooks.redeliver`

`POST /webhooks/{id}/deliveries/{eventId}/redeliver`

Scope: `webhooks`

A delivered or failed event starts again with the full schedule. 409 conflict while it is still being delivered, or when the endpoint is turned off (a webhook.test can be resent to a turned-off endpoint).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A webhook endpoint's id. |
| `eventId` | path | string | Yes | An event's id. |

### Responses

- `202` The delivery, on its way again. ([`WebhookDelivery`](https://imgsearch.com/developers/reference/schemas.md#WebhookDelivery))
- `404` No such endpoint, event or delivery on this account. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `409` Still being delivered, or the endpoint is turned off. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `429` More than 30 manual actions in an hour. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Sends an event to this endpoint again.
# Needs IMGSEARCH_API_KEY, WEBHOOK_ID and EVENT_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/webhooks/$WEBHOOK_ID/deliveries/$EVENT_ID/redeliver" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Sends an event to this endpoint again.
# Needs IMGSEARCH_API_KEY, WEBHOOK_ID and EVENT_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/webhooks/{os.environ['WEBHOOK_ID']}/deliveries/{os.environ['EVENT_ID']}/redeliver",
    headers=headers,
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Sends an event to this endpoint again.
// Needs IMGSEARCH_API_KEY, WEBHOOK_ID and EVENT_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/webhooks/${process.env.WEBHOOK_ID}/deliveries/${process.env.EVENT_ID}/redeliver`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 202**

```json
{
    "object": "webhook_delivery",
    "id": "evt_01m8bkydbq3z14kddmwg7fy822",
    "event_type": "webhook.test",
    "event_created_at": "2026-11-26T09:45:48Z",
    "status": "pending",
    "attempts": 0,
    "next_attempt_at": "2026-11-26T09:45:48Z",
    "last_attempt_at": "2026-11-26T09:45:48Z",
    "response": {
        "ms": 1,
        "body": "ok",
        "error": null,
        "status": 200
    }
}
```

## An account event

<a id="webhook.event"></a>`webhook.event`

`POST (your endpoint URL)`

One POST per event and endpoint, signed as Standard Webhooks (https://www.standardwebhooks.com): webhook-id is the event id (the same on every attempt), webhook-timestamp the attempt's Unix time, and webhook-signature "v1," and the base64 HMAC-SHA256 of "{webhook-id}.{webhook-timestamp}.{body}" keyed with the base64 part of your whsec_ secret; during a rotation two signatures, separated by a space. Verify the raw body before parsing it and refuse timestamps more than 5 minutes off. Answer any 2xx within 10 seconds and do the work afterwards. Anything else (a redirect included: none is followed) is tried again after 30 s, 2 min, 10 min, 30 min, 1 h, 3 h, 6 h and 12 h, 9 attempts in all (a test gets one). Events can arrive twice or out of order: dedupe on webhook-id, and read the generation for its current state. An endpoint with no 2xx for 3 days is turned off and you are emailed.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `webhook-id` | header | string | Yes | The event id (evt_…), the same on every attempt. |
| `webhook-timestamp` | header | string | Yes | Unix seconds of this attempt. |
| `webhook-signature` | header | string | Yes | One or two "v1,{base64}" signatures, separated by a space. |

### Request body

`application/json`, [`Event`](https://imgsearch.com/developers/reference/schemas.md#Event)

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | Yes |  |
| `object` | "event" | Yes |  |
| `type` | EventType | Yes | What an event says. webhook.test goes only to the endpoint it tests. |
| `created_at` | string | Yes |  |
| `data` | one of GenerationEventData, ExportEventData, ArEventData, SoundtrackEventData, VoiceoverVideoEventData, BalanceLowEventData, WebhookTestEventData | Yes |  |

### Responses

- `2XX` Received. Any 2xx within 10 s; anything else is retried.
