Generator

Menu

AI GeneratorImages, video, audio and 3D

Browse categories

Docs menu
Webhooks

API reference

Webhooks

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

View as Markdown
For your agent https://imgsearch.com/llms.txt
On this page
GET /events

The account's events, oldest first #

  • events.index
  • 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

NameInTypeDescription
after query string 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 Only these event types, separated by commas.
limit query integer Items per page.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

GET /events/settings

The low-balance alert #

  • events.settings
  • webhooks

Responses

Examples

curl
# 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
# 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
// 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
{
    "object": "event_settings",
    "balance_low_below_usd": 0.5
}
Try it

The try-it panel needs JavaScript.

PATCH /events/settings

Set or turn off the low-balance alert #

  • events.settings.update
  • 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

FieldTypeDescription
balance_low_below_usdrequired number or null In US dollars, with at most three decimals. At least 0.001, At most 100.

Responses

Examples

curl
# 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
# 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
// 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
{
    "object": "event_settings",
    "balance_low_below_usd": 0.5
}
Try it

The try-it panel needs JavaScript.

GET /webhooks

Your webhook endpoints #

  • webhooks.index
  • webhooks

At most five; never with their secrets.

Responses

  • 200 Every endpoint of the account. (List)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /webhooks

Add an endpoint #

  • webhooks.store
  • 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

FieldTypeDescription
urlrequired string At most 2048 characters.
description string or null At most 200 characters.
event_types array of SubscribableEventType or null The types it receives; null or left out for every type. At least 1 items.

Responses

  • 201 The endpoint and its signing secret. (WebhookEndpointWithSecret)
  • 409 The account has five endpoints already. (Error)
  • 422 A refused address (fields.url says why) or event type. (Error)
  • 429 More than 30 changes in an hour. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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="
}
Try it

The try-it panel needs JavaScript.

GET /webhooks/{id}

One endpoint #

  • webhooks.show
  • webhooks

Parameters

NameInTypeDescription
idrequired path string A webhook endpoint's id.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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"
}
Try it

The try-it panel needs JavaScript.

DELETE /webhooks/{id}

Delete an endpoint and its delivery log #

  • webhooks.destroy
  • webhooks

Parameters

NameInTypeDescription
idrequired path string A webhook endpoint's id.

Responses

  • 204 Deleted.
  • 404 No such endpoint on this account. (Error)
  • 429 More than 30 changes in an hour. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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);
Try it

The try-it panel needs JavaScript.

PATCH /webhooks/{id}

Change an endpoint, or turn it off or on #

  • webhooks.update
  • 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

NameInTypeDescription
idrequired path string A webhook endpoint's id.

Request body

application/json

FieldTypeDescription
url string At most 2048 characters.
description string or null At most 200 characters.
event_types array of SubscribableEventType or null At least 1 items.
enabled boolean

Responses

  • 200 The endpoint. (WebhookEndpoint)
  • 404 No such endpoint on this account. (Error)
  • 422 A refused address or event type. (Error)
  • 429 More than 30 changes in an hour. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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"
}
Try it

The try-it panel needs JavaScript.

POST /webhooks/{id}/test

Send a webhook.test event #

  • webhooks.test
  • webhooks

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

Parameters

NameInTypeDescription
idrequired path string A webhook endpoint's id.

Responses

  • 202 The test event's delivery, on its way. (WebhookDelivery)
  • 404 No such endpoint on this account. (Error)
  • 429 More than 30 manual actions in an hour. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /webhooks/{id}/rotate-secret

A new signing secret #

  • webhooks.rotate-secret
  • 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

NameInTypeDescription
idrequired path string A webhook endpoint's id.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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="
}
Try it

The try-it panel needs JavaScript.

GET /webhooks/{id}/deliveries

An endpoint's delivery log, newest first #

  • webhooks.deliveries
  • webhooks

Parameters

NameInTypeDescription
idrequired path string A webhook endpoint's id.
status query string One of: pending, delivered, failed
limit query integer Items per page.
cursor query string 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)
  • 404 No such endpoint on this account. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

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

Send an event to this endpoint again #

  • webhooks.redeliver
  • 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

NameInTypeDescription
idrequired path string A webhook endpoint's id.
eventIdrequired path string An event's id.

Responses

  • 202 The delivery, on its way again. (WebhookDelivery)
  • 404 No such endpoint, event or delivery on this account. (Error)
  • 409 Still being delivered, or the endpoint is turned off. (Error)
  • 429 More than 30 manual actions in an hour. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
    }
}
Try it

The try-it panel needs JavaScript.

POST Your endpoint URL

An account event #

  • webhook.event

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

NameInTypeDescription
webhook-idrequired header string The event id (evt_…), the same on every attempt.
webhook-timestamprequired header string Unix seconds of this attempt.
webhook-signaturerequired header string One or two "v1,{base64}" signatures, separated by a space.

Request body

application/json, Event

FieldTypeDescription
idrequired string
objectrequired "event"
typerequired EventType What an event says. webhook.test goes only to the endpoint it tests.
created_atrequired string
datarequired one of GenerationEventData, ExportEventData, ArEventData, SoundtrackEventData, VoiceoverVideoEventData, BalanceLowEventData, WebhookTestEventData

Responses

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