Guides
Webhooks
Account events, webhook endpoints, signatures, retries and the events feed.
https://imgsearch.com/llms.txt
When something finishes on your account, ImgSearch writes an event. You can receive events as signed POSTs to your own server (webhooks), or read them from the events feed. Both need the webhooks scope, which API keys can carry and OAuth apps never get. People can manage the same endpoints at Account → Webhooks on the website.
Every generation of the account makes events, whatever started it: the website, the API or the MCP server.
Events #
| Event | When |
|---|---|
generation.succeeded |
A generation finished; its files are ready. |
generation.failed |
A generation failed; its price was refunded. |
generation.canceled |
A generation was canceled through the API. |
generation.export.succeeded |
A 3D model export (another format or a chosen height) finished. |
generation.export.failed |
A 3D model export failed. |
generation.ar.succeeded |
The View in AR files of a 3D model, at one height, are ready. |
generation.ar.failed |
The View in AR files of a 3D model could not be made. |
generation.soundtrack.succeeded |
Music laid on a clip finished. |
generation.soundtrack.failed |
Music laid on a clip failed. |
generation.voiceover_video.succeeded |
A voiceover laid on a clip finished. |
generation.voiceover_video.failed |
A voiceover laid on a clip failed. |
balance.low |
The account’s spendable AI balance fell below its alert threshold. |
webhook.test |
A test event, sent only to the endpoint being tested. |
An endpoint receives every type unless you give it a list (event_types). webhook.test goes only to the endpoint being tested.
Payload #
Every webhook body is exactly the event object the feed lists:
{
"id": "evt_01m6v1pnkph7e6ma5j3xm995jc",
"object": "event",
"type": "generation.succeeded",
"created_at": "2026-11-07T13:03:27Z",
"data": {
"id": "01m6v1pm05dkbzdtxz90gjjr3h",
"kind": "image",
"model": "openai/gpt-image-2.5-sunburst",
"status": "succeeded",
"charged_usd": 0.015,
"outputs": [{"n": 0, "mime": "image/png"}],
"error": null
}
}
It is short on purpose: no prompt, title, caption or file link. Read the generation (GET /generations/{id}) for the rest; it is always the current state. Side actions add their own block (export, ar, soundtrack or voiceover_video, each with its status and error), balance.low carries available_usd and below_usd, and webhook.test carries endpoint_id and message. The reference has every shape.
Endpoints #
POST /webhooks adds an endpoint (reference):
url: an https address on port 443 of your own server, whose host resolves to public addresses only. It is checked again before every delivery. A refused address answers422with the reason indetails.fields.url.description(optional) andevent_types(optional; every type when left out).- The answer carries the signing
secret(whsec_…). It is shown only this once: store it.
An account can have 5 endpoints (one more answers 409 conflict with details.limit). Creating, changing and deleting endpoints are limited to 30 an hour, and tests, resends and rotations to another 30 an hour (429 rate_limited).
# 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
# 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))
// 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));
{
"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="
}
Signing and verifying #
Deliveries are signed as Standard Webhooks:
webhook-id: the event id (evt_…), the same on every attempt.webhook-timestamp: the attempt’s Unix time in seconds.webhook-signature:v1,and the base64 HMAC-SHA256 of{webhook-id}.{webhook-timestamp}.{body}, keyed with the base64-decoded part of yourwhsec_secret. During a rotation there are two, separated by a space.
Verify the raw body as it arrived, before parsing it, and refuse timestamps more than 5 minutes off. These verifiers check themselves against test vectors when you run the file directly (they print ok):
# Verifies an ImgSearch webhook (Standard Webhooks). Pass your endpoint's whsec_ secret, the request's headers (lower-case
# names) and its raw body as bytes, before any JSON parsing. Raises ValueError when the request is not from ImgSearch.
# Run this file directly (python3 verify.py) to check it against the test vectors; it prints "ok".
import base64, hashlib, hmac, time
def verify(secret, headers, body, now=None):
msg_id, ts = headers["webhook-id"], headers["webhook-timestamp"]
if abs((now or time.time()) - int(ts)) > 300:
raise ValueError("timestamp too old or too new")
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{ts}.".encode() + body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
for signature in headers["webhook-signature"].split(" "):
version, _, value = signature.partition(",")
if version == "v1" and hmac.compare_digest(value, expected):
return
raise ValueError("no valid signature")
if __name__ == "__main__":
# a. The Standard Webhooks reference vector.
verify("whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw", {"webhook-id": "msg_p5jXN8AQM9LWM0D4loKWxJek", "webhook-timestamp": "1614265330",
"webhook-signature": "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE="}, b'{"test": 2432232314}', now=1614265330)
# b. ImgSearch during a rotation: either secret verifies; a changed body does not.
body = b'{"id":"evt_01jbz8x7k2m4n6p8q0r2s4t6v8","object":"event","type":"generation.succeeded","created_at":"2026-11-04T00:00:00Z","data":{"id":"01jbz8w5e3f5g7h9j1k3m5n7p9","kind":"image","model":"openai/gpt-image-2","status":"succeeded","charged_usd":0.015,"outputs":[{"n":0,"mime":"image/png"}],"error":null}}'
headers = {"webhook-id": "evt_01jbz8x7k2m4n6p8q0r2s4t6v8", "webhook-timestamp": "1793750400",
"webhook-signature": "v1,gAZp/YTxlwLR8oEcRc6ouN4LiSbkli/4fapDj6M3omU= v1,PQnNzTp4ocYRZE1vRtz3hB7WN9bX5198dhH7iYAOIb4="}
verify("whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=", headers, body, now=1793750400)
verify("whsec_ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj8=", headers, body, now=1793750400)
try:
verify("whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=", headers, body + b" ", now=1793750400)
raise SystemExit("a changed body verified")
except ValueError:
print("ok")
// Verifies an ImgSearch webhook (Standard Webhooks). Pass your endpoint's whsec_ secret, the request's headers (lower-case
// names) and its raw body as a string, before any JSON parsing. Throws when the request is not from ImgSearch. Run this
// file directly (node verify.js; an ES module) to check it against the test vectors; it prints "ok".
import crypto from 'node:crypto';
import { pathToFileURL } from 'node:url';
export function verify(secret, headers, body, now = Date.now() / 1000) {
const id = headers['webhook-id'];
const ts = headers['webhook-timestamp'];
if (Math.abs(now - Number(ts)) > 300) throw new Error('timestamp too old or too new');
const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
const expected = Buffer.from(crypto.createHmac('sha256', key).update(`${id}.${ts}.${body}`).digest('base64'));
const ok = headers['webhook-signature'].split(' ').some((signature) => {
const [version, value = ''] = signature.split(',');
const given = Buffer.from(value);
return version === 'v1' && given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
if (!ok) throw new Error('no valid signature');
}
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
// a. The Standard Webhooks reference vector.
verify('whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw', { 'webhook-id': 'msg_p5jXN8AQM9LWM0D4loKWxJek', 'webhook-timestamp': '1614265330',
'webhook-signature': 'v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=' }, '{"test": 2432232314}', 1614265330);
// b. ImgSearch during a rotation: either secret verifies; a changed body does not.
const body = '{"id":"evt_01jbz8x7k2m4n6p8q0r2s4t6v8","object":"event","type":"generation.succeeded","created_at":"2026-11-04T00:00:00Z","data":{"id":"01jbz8w5e3f5g7h9j1k3m5n7p9","kind":"image","model":"openai/gpt-image-2","status":"succeeded","charged_usd":0.015,"outputs":[{"n":0,"mime":"image/png"}],"error":null}}';
const headers = { 'webhook-id': 'evt_01jbz8x7k2m4n6p8q0r2s4t6v8', 'webhook-timestamp': '1793750400',
'webhook-signature': 'v1,gAZp/YTxlwLR8oEcRc6ouN4LiSbkli/4fapDj6M3omU= v1,PQnNzTp4ocYRZE1vRtz3hB7WN9bX5198dhH7iYAOIb4=' };
verify('whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=', headers, body, 1793750400);
verify('whsec_ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj8=', headers, body, 1793750400);
let refused = false;
try {
verify('whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=', headers, body + ' ', 1793750400);
} catch (error) {
refused = true;
}
if (!refused) throw new Error('a changed body verified');
console.log('ok');
}
<?php
// Verifies an ImgSearch webhook (Standard Webhooks). Pass your endpoint's whsec_ secret, the request's headers (lower-case
// names) and its raw body, before any JSON parsing. Throws when the request is not from ImgSearch. Run this file
// directly (php verify.php) to check it against the test vectors; it prints "ok".
function verifyWebhook($secret, $headers, $body, $now = null)
{
$id = $headers['webhook-id'];
$timestamp = $headers['webhook-timestamp'];
if (abs(($now ?? time()) - (int) $timestamp) > 300) {
throw new RuntimeException('timestamp too old or too new');
}
$key = base64_decode(substr($secret, strlen('whsec_')));
$expected = base64_encode(hash_hmac('sha256', $id.'.'.$timestamp.'.'.$body, $key, true));
foreach (explode(' ', $headers['webhook-signature']) as $signature) {
[$version, $value] = array_pad(explode(',', $signature, 2), 2, '');
if ($version === 'v1' && hash_equals($expected, $value)) {
return;
}
}
throw new RuntimeException('no valid signature');
}
if (PHP_SAPI === 'cli' && realpath($argv[0] ?? '') === __FILE__) {
// a. The Standard Webhooks reference vector.
verifyWebhook('whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw', ['webhook-id' => 'msg_p5jXN8AQM9LWM0D4loKWxJek', 'webhook-timestamp' => '1614265330',
'webhook-signature' => 'v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE='], '{"test": 2432232314}', 1614265330);
// b. ImgSearch during a rotation: either secret verifies; a changed body does not.
$body = '{"id":"evt_01jbz8x7k2m4n6p8q0r2s4t6v8","object":"event","type":"generation.succeeded","created_at":"2026-11-04T00:00:00Z","data":{"id":"01jbz8w5e3f5g7h9j1k3m5n7p9","kind":"image","model":"openai/gpt-image-2","status":"succeeded","charged_usd":0.015,"outputs":[{"n":0,"mime":"image/png"}],"error":null}}';
$headers = ['webhook-id' => 'evt_01jbz8x7k2m4n6p8q0r2s4t6v8', 'webhook-timestamp' => '1793750400',
'webhook-signature' => 'v1,gAZp/YTxlwLR8oEcRc6ouN4LiSbkli/4fapDj6M3omU= v1,PQnNzTp4ocYRZE1vRtz3hB7WN9bX5198dhH7iYAOIb4='];
verifyWebhook('whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=', $headers, $body, 1793750400);
verifyWebhook('whsec_ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj8=', $headers, $body, 1793750400);
try {
verifyWebhook('whsec_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=', $headers, $body.' ', 1793750400);
exit("a changed body verified\n");
} catch (RuntimeException $exception) {
echo "ok\n";
}
}
Answer any 2xx within 10 seconds and do the work afterwards. Events can arrive twice or out of order: keep the webhook-ids you handled and skip repeats, and read the generation for its current state.
Retries, turning off, tests and rotation #
- Retries. Anything but a
2xx(a redirect included: none is followed) is tried again after 30 seconds, 2 minutes, 10 minutes, 30 minutes, 1 hour, 3 hours, 6 hours and 12 hours: 9 attempts in all.GET /webhooks/{id}/deliveriesshows each event’s delivery, its attempts and the last answer. - Resending.
POST /webhooks/{id}/deliveries/{eventId}/redeliverstarts a delivered or failed event again with the full schedule. While it is still being delivered, or while the endpoint is turned off, it answers409 conflict(awebhook.testcan still be resent). - Turning off. An endpoint with no
2xxfor 3 days is turned off and the account holder gets an email.PATCHit withenabled: true(orfalseto turn it off yourself). Nothing missed while it was off is resent by itself; resend what you need. A newurlstarts the failure count again. - Testing.
POST /webhooks/{id}/testsends awebhook.testevent to that endpoint, once, even when it is turned off. - Rotating.
POST /webhooks/{id}/rotate-secretanswers a new secret, shown 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.
The events feed and balance.low #
GET /events lists the account’s events of the last 30 days, oldest first. Send the last id you handled as after to get only newer ones, and types to narrow them. Events appear 2 seconds after they happen, so polling with after never skips one. The answer is {object, data, has_more}: while has_more is true, ask again with the last id. An unknown after, or one older than 30 days, answers 422 (details.fields.after).
# 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"
# 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))
// 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));
{
"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 example answers come from a local test server, where generation uses the test model
local/echo. Ids, times, models and prices in your answers will differ.
balance.low warns before the account runs out. Set the threshold with PATCH /events/settings (balance_low_below_usd, in US dollars from 0.001 to 100; null turns it off). The event is sent once when the spendable AI balance falls below it, and again only after it was back at or above it and a day has passed.
# 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
}'
# 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))
// 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));
{
"object": "event_settings",
"balance_low_below_usd": 0.5
}