Skip to main content

What are webhooks?

Image generation is asynchronous. When you call POST /image-generation/{model_identifier}, BabySea returns a generation_id immediately and begins processing in the background. Webhooks let BabySea notify your server the moment that processing finishes, instead of your code polling GET /image-generation/{generation_id} repeatedly.

When does BabySea send a webhook?

BabySea sends a POST request to your endpoint for these events:
EventWhen
generation.startedThe generation was submitted to an inference provider
generation.completedAll output images are ready
generation.failedAll inference providers were exhausted without success
generation.canceledThe generation was canceled by the user
webhook.testYou clicked Send test event in your workspace
Each delivery contains a webhook_data object with a snapshot of the generation at the time of the event. See Events for the full payload reference.

Endpoint requirements

Your webhook endpoint must:
  • Accept POST requests with a Content-Type: application/json body.
  • Respond with any 2xx status code within 10 seconds.
  • Be publicly reachable over HTTPS.
BabySea does not follow redirects. If your endpoint returns a non-2xx response or times out, BabySea will retry the delivery up to 5 times with exponential backoff. See Retry and delivery for the full retry schedule and auto-disable behavior.

Request headers

Every delivery includes the following HTTP headers:
HeaderDescription
Content-TypeAlways application/json
X-BabySea-SignatureHMAC-SHA256 signature, see Verify signature
X-BabySea-EventEvent type, e.g. generation.completed
X-BabySea-Delivery-IdUUID matching webhook_delivery_id in the payload (use as an idempotency key)
X-BabySea-TimestampISO 8601 timestamp matching webhook_timestamp in the payload

Setting up your endpoint

  1. Navigate to your workspace in the BabySea dashboard.
  2. Add a webhook URL. BabySea generates a signing secret, copy it immediately, it is shown only once.
  3. Select which events to subscribe to (all four are enabled by default).
  4. Click Send test event to verify your endpoint is reachable and correctly verifying signatures.
Store your webhook secret as an environment variable (BABYSEA_WEBHOOK_SECRET). Never commit it to source code. If you suspect your secret has been compromised, rotate it from your workspace, and BabySea signs all new deliveries with the new secret immediately.

Delivery guarantees

Because BabySea guarantees at-least-once delivery, your endpoint may receive the same event more than once (e.g., during infrastructure failover). Use the webhook_delivery_id as an idempotency key to avoid processing duplicates. See Retry and delivery for details.
PropertyGuarantee
DeliveryAt least once
OrderingNot guaranteed across events
IdempotencyUse webhook_delivery_id
RetryUp to 5 attempts (exponential)
Auto-disableAfter 15 consecutive failures
DLQ retention72 hours