Webhooks
Webhooks notify your server when an asynchronous audio, image or video job ends. Text models return results directly and do not use webhooks.
Register an endpoint
- Call Create a webhook endpoint with a publicly reachable HTTPS URL.
- Save the signing secret that starts with
whsec_from the response right away. It is shown only this once. - Pass the endpoint's
webhook_endpoint_idwhen you submit generation requests.
When a job succeeds or fails, a job.succeeded or job.failed event is sent to the endpoint. Call Send a test event to send an endpoint.test event and check your receiver.
Examples of the three events:
{
"id": "evt_0123456789abcdef0123456789abcdef",
"api_version": "2026-09-01",
"created_at": "2026-10-06T10:00:00Z",
"type": "job.succeeded",
"data": {
"job": {
"id": "job_xxx",
"type": "tts",
"status": "succeeded",
"finished_at": "2026-10-06T10:00:00Z",
"result_endpoint": "https://shixux.com/api/v1/jobs/job_xxx/result"
}
}
}A notification contains the job status and result_endpoint, the endpoint for fetching the result. It does not contain a file download URL. After receiving job.succeeded, call Retrieve a job result to get the download URL.
Verify signatures
Every notification carries these headers:
| Header | Description |
|---|---|
X-YB-Timestamp | Send time as a Unix timestamp in seconds |
X-YB-Signature | Signature in the form v1=<hex digest>; during secret rotation it may contain several comma-separated values |
X-YB-Delivery-ID | Delivery ID used for deduplication |
To verify a notification:
- Concatenate the
X-YB-Timestampvalue, a period.and the raw request body bytes, and compute HMAC-SHA256 with the signing secret. - Using a constant-time comparison, check that the result matches any
v1value inX-YB-Signature. - Reject requests whose timestamp differs from the current time by more than 5 minutes.
Compute the signature over the raw request body as received; do not parse the JSON and serialize it again. The examples below are ready to use. In Node.js, obtain the raw Buffer first; in Python, use the raw bytes.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function(a,b,c){let d=b["x-yb-timestamp"],e=b["x-yb-signature"];if("string"!=typeof d||!/^\d+$/.test(d)||"string"!=typeof e)return!1;let f=Number(d);if(!Number.isSafeInteger(f)||Math.abs(Date.now()/1e3-f)>300)return!1;let g=(0,cR.createHmac)("sha256",c).update(d+".").update(a).digest();return e.split(",").some(a=>{let b=a.trim();return!!/^v1=[a-fA-F0-9]{64}$/.test(b)&&(0,cR.timingSafeEqual)(Buffer.from(b.slice(3),"hex"),g)})}Respond quickly and deduplicate
After verifying the signature, return a 2xx status within 5 seconds and process your business logic asynchronously.
Webhooks are delivered at least once: the same event may arrive more than once, and ordering across jobs is not guaranteed. Deduplicate by X-YB-Delivery-ID so that repeated deliveries do not repeat business operations.
Timeouts and retries
Each delivery attempt times out after 5 seconds. If no 2xx response is received, the delivery is retried after 30 seconds, 2 minutes, 10 minutes, 30 minutes, 2 hours, 6 hours and 24 hours, for at most 8 attempts in total.
- 3xx redirects are not followed.
- If the endpoint returns
429or503withRetry-After, the next attempt is delayed accordingly, by up to 24 hours. - After all attempts fail, check the cause in delivery records and call Redeliver an event.
While your endpoint is unavailable, you can still use Retrieve a job and Retrieve a job result to follow job progress.
Rotate the signing secret
Call Rotate the signing secret to get a new secret and store it securely. For 48 hours after rotation, notifications are signed with both the new and the previous secret, and a match on any v1 value is valid. Switch your receiver to the new secret during this period. You cannot rotate again until the 48-hour transition of the previous rotation has ended.
Manage endpoints
List endpoints · Retrieve an endpoint · Update an endpoint · Delete an endpoint · Rotate the signing secret · List deliveries · Redeliver an event
After an endpoint is deleted, deliveries that have not completed are no longer sent.