Callbacks (Webhook)
Pass a callback_url (must start with https://) when you create a task. When the task completes or fails, the system sends a POST notification to your server, so you don't have to keep querying the task status.
When notifications are sent
- Once when the task completes (
status = 20). - Once when the task fails (
status = 30). Credits for failed tasks have been refunded automatically; see Credits and Billing. - No notification is sent when a task is canceled.
Notification content
POST {your callback_url}
Content-Type: application/json
X-Signature: <HMAC-SHA256 signature, see below>
X-Timestamp: 1799999999
{
"public_id": "01JABCXYZULID",
"status": 20,
"error_code": null,
"payload": null
}
The notification contains only the task status (for the meaning of status, see Query Tasks and Download Results), not result or files. After receiving a notification, call GET /api/tasks/{public_id} to get the full result; the cover image for video tasks is also available there. See "Video cover image" in Query Tasks and Download Results.
payload is the payload you sent when creating the task, returned as-is; it is null if you didn't send one. Use it for your own data, such as an order number.
Exception: notifications for face age detection also include result with the detection result attached; see Face Age Detection. Notifications for all other tasks contain only the four fields above.
Verifying the signature
X-Signature is a hexadecimal string computed with HMAC-SHA256 over the raw request body, using your account's webhook secret:
X-Signature = hash_hmac('sha256', <raw request body>, <your webhook_secret>)
Node.js verification example:
const crypto = require('crypto')
function isValidSignature(rawBody, signatureHeader, webhookSecret) {
const expected = crypto.createHmac('sha256', webhookSecret).update(rawBody).digest('hex')
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signatureHeader))
}
Compute the signature over the raw body string you received, not over re-serialized JSON; otherwise differences in field order or whitespace will cause a mismatch.
X-Timestamp is the Unix timestamp at the time of sending. Whether to check it to prevent replay attacks is up to you; the system does not check it.
Viewing and rotating the webhook secret
The webhook secret is an account-level setting shared by all tasks in the same account. You can view or rotate it on the Webhook page in the console.
After rotation, the old secret stops working immediately, with no grace period. The new secret is only generated at the moment of rotation, so update the setting on your server right after rotating. Notifications received between rotating and updating your setting will fail verification, but the system retries them automatically (see "Retry policy" below), so once you've updated, you'll receive them with the new secret.
Retry policy
If a notification fails (timeout, connection failure, or your server responds with a non-2xx status), the system retries automatically, with increasing intervals:
| Retry | Interval since previous attempt |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 6 hours |
Retries stop after 5 failed attempts. You may receive the notification for the same public_id and status more than once, so make sure duplicate deliveries aren't processed twice.