Webhooks
Receive generation results without continuous polling. Pass an HTTPS endpoint in webhook_url when you start a generation, and Synesta sends it a POST once the generation becomes done or failed.
Set up
- Create a signing secret in the API console. It starts with
whsec_and is shown once. One secret covers the whole account: it signs deliveries for every key. - Pass
webhook_urlwhen you start a generation:
curl -X POST https://api.synesta.ai/v1/generations \
-H "Authorization: Bearer $SYNESTA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"type":"image","model":"MODEL_ID","prompt":"Editorial portrait in soft daylight","webhook_url":"https://example.com/webhooks/synesta"}'Your endpoint must be publicly reachable over HTTPS (port 443), accept a JSON body and respond within five seconds. Without a secret, a request with webhook_url returns 422 webhook_secret_required.
Payload
All deliveries use the same envelope. data holds the same object that GET /generations/{id} returns.
{
"type": "generation.completed",
"timestamp": "2026-12-02T12:05:12Z",
"data": {
"id": 3680,
"type": "image",
"status": "done",
"outputs": [
{ "url": "https://cdn.synesta.ai/labs/outputs/image/2026/12/....png", "kind": "image", "mime": "image/png" }
],
"cost_usd": 0.48,
"refunded": false
}
}type is generation.completed or generation.failed. For generation.failed, data.error explains why, and the price is already refunded to the API balance.
Verify signatures
Deliveries are signed using the Standard Webhooks specification. Verify every delivery before trusting it: anyone who knows your endpoint URL can send it a request. Each delivery has three headers:
| Header | Value |
|---|---|
webhook-id | Event identifier. It stays the same across retries of the same event. |
webhook-timestamp | Unix time in seconds when the delivery was signed. |
webhook-signature | One or more space-separated signatures in the form v1,<base64>. |
With a library
The official Standard Webhooks library checks the signature and rejects timestamps outside a five-minute tolerance. Verify the raw request body before parsing JSON: re-serialized JSON does not match the signature.
import os
from standardwebhooks import Webhook, WebhookVerificationError
webhook = Webhook(os.environ["SYNESTA_WEBHOOK_SECRET"])
try:
event = webhook.verify(raw_body, headers)
except WebhookVerificationError:
return Response(status=400)import { Webhook } from 'standardwebhooks';
const webhook = new Webhook(process.env.SYNESTA_WEBHOOK_SECRET!);
try {
const event = webhook.verify(rawBody, headers);
} catch {
return new Response(null, { status: 400 });
}Install with pip install standardwebhooks or npm install standardwebhooks. Libraries for other languages are listed in the Standard Webhooks repository.
Manually
- Remove the
whsec_prefix from the secret and base64-decode the rest to get the HMAC key. - Build the signed content
{webhook-id}.{webhook-timestamp}.{raw body}. - Compute HMAC-SHA256 of the signed content with the key and base64-encode the result.
- Compare it with each
v1,entry ofwebhook-signatureusing a constant-time comparison. Accept the delivery if any entry matches. - Reject deliveries whose
webhook-timestampis more than five minutes from your current time.
Rotate the secret
Reissue the secret in the console if it may have been exposed. The new secret takes effect immediately, and the previous one keeps signing for 24 hours. During that window webhook-signature carries one signature per secret, so update your server before the previous secret expires. At most two secrets are valid at the same time.
Delivery and retries
- Return any 2xx after durably recording the event. We don't read the response body, keep it short.
- 5xx, 408 and 429 responses, timeouts and network failures are retried: up to 6 attempts in total with growing pauses (30 s, 2 min, 8 min, 32 min, 1 h).
- Other 4xx responses are treated as permanent and are not retried.
- Redirects are not followed, and we never send to private or internal addresses.
- Duplicate deliveries are possible. Deduplicate by
webhook-id. - If delivery fails permanently, retrieve the result by polling. The last 50 deliveries are visible in the API console.