Skip to navigation

Add a webhook_url to a request and Ideogram sends the finished result to that URL. Any v2 endpoint that has a webhook_url field runs asynchronously when you supply it: the request returns a generation_id straight away, and Ideogram sends a JSON POST to your URL once every output for the request has finished. Each delivery is signed with Ed25519 so you can confirm it came from Ideogram before acting on it.

curl -X POST https://api.ideogram.ai/v2/image/generate/ideogram-4-5 \
-H "Api-Key: $IDEOGRAM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A ceramic mug on a wooden table, soft window light",
"webhook_url": "https://example.com/ideogram-webhook"
}'

The response carries the identifier to record, and no data:

{
"generation_id": "xtdZiqPwRxqY1Y7NExFmzB",
"generation_kind": "sampling",
"seed": 12345
}

What Ideogram delivers

The request body contains:

  • generation_id: URL-safe base64 ID of the generation. Use it to match the delivery to your original request, and to poll the generation.
  • created: the time the generation was created.
  • data: an array of results. Each item has an object_type that tells you its fields.
  • usage_cost_usd_micros: the cost of the request in millionths of a US dollar, when the request uses variable usage-based pricing.

An image generation delivers image.generation items:

{
"generation_id": "xtdZiqPwRxqY1Y7NExFmzB",
"created": "2025-01-23T04:56:07Z",
"data": [
{
"object_type": "image.generation",
"url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png",
"prompt": "A ceramic mug on a wooden table, soft window light",
"resolution": "2048x2048",
"seed": 12345,
"is_image_safe": true
}
]
}

Other endpoints deliver other item types. Each one is a separate shape, so read object_type before reading the other fields:

object_typeSent byFields
image.generationMost image endpointsurl, prompt, resolution, seed, is_image_safe
image.without-prompt-or-seedEndpoints whose results have no prompt or seed, such as the toolsurl, resolution, is_image_safe
svg.generationVector endpointsasset_id, url, mime_type (image/svg+xml), width, height

When an image doesn’t pass the safety check, its is_image_safe is false and its url is an empty string.

For video results, poll GET /v2/generations/{generation_id} when the delivery arrives and read the video fields from that response.

Ideogram sends a webhook only when a generation completes. A generation that fails sends nothing. Poll GET /v2/generations/{generation_id} to read its status and failure_reason.

Request headers

Every delivery includes these headers:

HeaderValue
X-Ideogram-Webhook-Generation-IdURL-safe base64 ID of the generation. Matches generation_id in the body.
X-Ideogram-Webhook-User-IdURL-safe base64 ID of the account that initiated the request.
X-Ideogram-Webhook-TimestampUnix seconds (decimal) at which the request was signed. Each delivery attempt is signed again, so a retry carries a new timestamp.
X-Ideogram-Webhook-Key-IdThe kid of the signing key. A hint for which public key to try first, not a requirement.
X-Ideogram-Webhook-SignatureEd25519 signature, lowercase hex.
Content-Typeapplication/json

Verifying the signature

  1. Fetch the public keys. Send a GET to https://api.ideogram.ai/v1/.well-known/jwks.json. The same keys sign deliveries for v1 and v2 requests. The response lists Ed25519 public keys in JWK form. Each key’s x field is the 32-byte public key, base64url-encoded with no padding. The key set is cacheable; refresh it if a signature ever fails to verify against your cached copy, in case the keys rotated.

  2. Rebuild the signed message. Concatenate these four values in this exact order, joined with single newline (\n) separators, then encode the result as UTF-8:

    {X-Ideogram-Webhook-Generation-Id}
    {X-Ideogram-Webhook-User-Id}
    {X-Ideogram-Webhook-Timestamp}
    {sha256_hex(raw request body bytes)}

    Hash the raw body bytes exactly as received. Do not parse and re-serialize the JSON first, or the hash will not match what Ideogram signed.

  3. Verify against the published keys. Decode X-Ideogram-Webhook-Signature from hex and check it against each public key in the set. If any key verifies, the webhook is authentic. If none do, reject the request. The X-Ideogram-Webhook-Key-Id header tells you which key to try first, but fall back to the others so signatures stay verifiable across key rotations.

Python example

import base64
import hashlib
import time
import requests
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
JWKS_URL = "https://api.ideogram.ai/v1/.well-known/jwks.json"
KEY_CACHE_SECONDS = 24 * 60 * 60
MAX_AGE_SECONDS = 5 * 60 # reject deliveries signed more than five minutes ago
_cached_keys: list[Ed25519PublicKey] = []
_cached_at = 0.0
def _b64url_decode(value: str) -> bytes:
return base64.urlsafe_b64decode(value + "=" * (-len(value) % 4))
def ideogram_public_keys(refresh: bool = False) -> list[Ed25519PublicKey]:
global _cached_keys, _cached_at
if refresh or not _cached_keys or time.time() - _cached_at > KEY_CACHE_SECONDS:
jwks = requests.get(JWKS_URL, timeout=5).json()
_cached_keys = [
Ed25519PublicKey.from_public_bytes(_b64url_decode(jwk["x"])) for jwk in jwks["keys"]
]
_cached_at = time.time()
return _cached_keys
def _verifies(keys: list[Ed25519PublicKey], signature: bytes, message: bytes) -> bool:
for public_key in keys:
try:
public_key.verify(signature, message)
return True
except InvalidSignature:
continue
return False
def verify_webhook(headers, body: bytes) -> bool:
"""Return True if Ideogram signed this delivery. `body` is the raw request bytes."""
# Frameworks differ in header case (Flask: X-Ideogram-..., FastAPI and Express:
# x-ideogram-...), so compare names in lower case.
lower = {name.lower(): value for name, value in dict(headers).items()}
try:
generation_id = lower["x-ideogram-webhook-generation-id"]
user_id = lower["x-ideogram-webhook-user-id"]
timestamp = lower["x-ideogram-webhook-timestamp"]
signature = bytes.fromhex(lower["x-ideogram-webhook-signature"])
except (KeyError, ValueError):
return False
if abs(time.time() - float(timestamp)) > MAX_AGE_SECONDS:
return False # an old signature: reject it as a possible replay
body_hash = hashlib.sha256(body).hexdigest()
message = f"{generation_id}\n{user_id}\n{timestamp}\n{body_hash}".encode("utf-8")
if _verifies(ideogram_public_keys(), signature, message):
return True
# The keys may have rotated since they were cached: refresh once and try again.
return _verifies(ideogram_public_keys(refresh=True), signature, message)

Each delivery attempt is signed again with a new X-Ideogram-Webhook-Timestamp, so a five-minute window rejects replayed requests without rejecting Ideogram’s retries.

The body passed to verify_webhook must be the raw request bytes exactly as Ideogram sent them. Read them from your web framework’s raw-body accessor, not from a parsed-then-re-serialized JSON object: re-serializing can reorder keys or change whitespace, which changes the bytes and makes the SHA-256 hash (and so the signature check) fail. Examples of the raw-body accessor:

  • Flask: request.get_data()
  • FastAPI / Starlette: await request.body()
  • Django: request.body
  • Express (Node): express.raw() middleware, then req.body (a Buffer)

A complete Flask handler:

from flask import Flask, request
app = Flask(__name__)
@app.post("/ideogram-webhook")
def ideogram_webhook():
body = request.get_data() # raw bytes as received; do NOT use request.get_json() here
if not verify_webhook(request.headers, body):
return {"error": "invalid signature"}, 400
payload = request.get_json() # now safe to parse for your application logic
# ... process payload["data"] ...
return {"ok": True}

The example caches the public keys for up to 24 hours and refreshes them once when a signature fails to verify, in case the keys rotated.

Retries, idempotency, and polling

Return a 2xx status within 10 seconds to acknowledge a delivery. Ideogram retries when your endpoint times out, can’t be reached, or returns 429 or a 5xx status. It doesn’t follow redirects and doesn’t retry a 3xx or any other 4xx status. Design your handler for this:

  • Make it idempotent. The same generation_id can arrive more than once (for example, a retry after your endpoint was briefly slow or unavailable). Key your completion state on generation_id, treat an already-processed generation_id as a no-op, and return 2xx so the retries stop.
  • Delivery is not guaranteed. Ideogram retries a delivery only a limited number of times before dropping it, so a webhook may never arrive (for example, if your endpoint is down for an extended period). Do not rely on the webhook as your only way to get a result.
  • Fall back to polling. If you do not receive a delivery, poll GET /v2/generations/{generation_id} with the generation_id the request returned. Its status is pending, completed or failed; a completed generation returns the same data. For a v1 request, poll GET /v1/generations/{generation_id} instead.

A handler that is idempotent is different from a request that is. The API takes no idempotency key, and sending the same request twice starts two generations. See Idempotency and safe retries.

Troubleshooting

ProblemWhat to check
The signature doesn’t verifyHash the raw request bytes, not re-serialized JSON. Refresh your cached public keys and try every key in the set.
The same delivery arrives twiceExpected after a retry. Process each generation_id once and return 2xx for repeats.
No delivery arrivesYour webhook_url must be a publicly reachable HTTPS URL that answers with 2xx within 10 seconds, without a redirect. A failed generation sends no webhook.
You need the result nowPoll GET /v2/generations/{generation_id}. Polling is rate limited; on a 429, wait for the time in Retry-After.