Webhooks send signed HTTPDocumentation Index
Fetch the complete documentation index at: https://docs.babysea.ai/llms.txt
Use this file to discover all available pages before exploring further.
POST events to your server when generation state changes or a low-credit threshold is crossed.
Event types
| Event | Sent when |
|---|---|
generation.started | A generation is accepted and processing begins. |
generation.completed | A generation succeeds and output files are available. |
generation.failed | A generation fails. |
generation.canceled | A generation is canceled. |
credits.low_balance | The account balance crosses an enabled low-balance threshold. |
webhook.test | You send a test event from the dashboard. |
Set up an endpoint
Create a receiver
Add an HTTPS route in your application that accepts
POST requests and
reads the raw request body before parsing JSON.Register the endpoint
Open Webhook in the dashboard, add the HTTPS URL, and choose the events
your server handles. Endpoint URLs must use public HTTPS on the default
HTTPS port and must not rely on redirects.
Store the secret
Copy the
whsec_... signing secret and store it in your secrets manager.
BabySea shows it once.Delivery headers
Every webhook delivery includes these headers:| Header | Value |
|---|---|
Content-Type | application/json |
X-BabySea-Signature | t=<unix_timestamp>,v1=<hmac_sha256_hex> |
X-BabySea-Event | Event type, such as generation.completed. |
X-BabySea-Timestamp | ISO timestamp for the delivery. |
X-BabySea-Delivery-Id | Unique delivery UUID. |
Verify signatures
BabySea signs the exact raw JSON body with HMAC-SHA256. The signed payload is:verifyWebhook() from the TypeScript SDK when possible.
TypeScript
verifyWebhook() rejects missing signatures, invalid signatures, malformed signature headers, and timestamps outside the tolerance window. The default tolerance is 300 seconds.
Generation payload
Generation lifecycle events share this shape:JSON
generation.failed can include generation_error and generation_error_code. generation.canceled can include credits_refunded.
Credit alert payload
credits.low_balance uses a billing payload instead of generation fields.
JSON
Delivery behavior
Generation lifecycle deliveries use retries. Credit alert, test, and replay deliveries are one-shot deliveries.| Event category | Timeout | Attempts | Retry behavior |
|---|---|---|---|
generation.* | 5 seconds per attempt | 5 total | Immediate, then after 0.5, 1.5, 3, and 5 seconds. |
credits.low_balance | 5 seconds | 1 total | No automatic retry. |
webhook.test | 10 seconds | 1 total | No automatic retry. |
| Replayed delivery | 10 seconds | 1 total | No automatic retry. |
2xx response marks the delivery successful. Generation endpoints are automatically disabled after 15 consecutive failed generation deliveries. When matching generation events arrive while an endpoint is disabled, BabySea queues them for later delivery.
| Queue behavior | Value |
|---|---|
| Queue retention | 72 hours |
| Deliver queued events | Sends pending items after you re-enable the endpoint. |
| Queued delivery attempts | One attempt per item with pacing and early stop after repeated failures. |
| Test events | Not queued. |
Idempotency in your handler
Webhook delivery is at-least-once for generation lifecycle events. Storewebhook_delivery_id before applying side effects so retries and replays do not duplicate work.
Recommended handler behavior:
- Verify
X-BabySea-Signatureagainst the raw body. - Reject events with stale timestamps.
- Store
webhook_delivery_idwith a unique constraint. - Return
2xxonly after durable side effects complete. - Return
4xxfor permanently invalid requests and5xxfor temporary failures.