Webhooks
Receive signed notifications when a task succeeds or fails.
Configure a receiver
Add up to 10 URLs in Webhook. Receivers must use publicly resolvable HTTPS on port 443, with no embedded credentials or fragment. Private/reserved IPs and redirects are rejected. Save the account secret securely; refreshing it changes the signing key for future delivery attempts.
Payload
{
"id": "evt_task_example_1",
"event": "task.success",
"data": {
"task_id": "task_example",
"endpoint": "image",
"model": "gpt-image-2.6-flare",
"status": "success",
"cost": 5,
"unit": "credit",
"create_at": 1794355200,
"image_url": "https://cdn.example.com/result.png",
"image_urls": [
"https://cdn.example.com/result.png"
],
"video_url": "",
"error": ""
}
}Verify signatures
X-Webhook-Signature is the lowercase hex HMAC-SHA256 of timestamp + "." + rawBody, using the full secret including its whsec_ prefix. The timestamp is in X-Webhook-Timestamp. Validate the signature and timestamp before processing.
import { createHmac, timingSafeEqual } from 'node:crypto'
// rawBody must contain the exact received bytes, before JSON parsing.
const timestamp = req.headers['x-webhook-timestamp']
const signature = req.headers['x-webhook-signature']
if (!/^\d+$/.test(timestamp || '') || Math.abs(Date.now()/1000 - Number(timestamp)) > 300) throw new Error('Expired webhook')
if (!/^[a-f0-9]{64}$/.test(signature || '')) throw new Error('Invalid signature')
const expected = createHmac('sha256', process.env.CHATART_WEBHOOK_SECRET)
.update(timestamp + '.').update(rawBody).digest()
if (!timingSafeEqual(expected, Buffer.from(signature, 'hex'))) throw new Error('Invalid signature')
// Deduplicate X-Webhook-Id in durable storage, enqueue work, then return HTTP 2xx.Delivery and retries
Delivery is at least once. Deduplicate using the stable X-Webhook-Id. Only HTTP 2xx acknowledges an event. The worker runs every minute and retries failed deliveries up to 8 attempts with exponential backoff capped at one hour. Timing depends on worker load. Deleting a receiver cancels its pending deliveries. New receivers apply to tasks that finish after registration; no historical replay is provided. Uncertain submissions require manual reconciliation and do not emit a success/failure event.
Deployment
The ChatArtPro portal migration and scheduler must be deployed, with API_PORTAL_WORKER_ENABLED=true. Without the worker, manual task polling still updates task state, but automatic callbacks are not delivered.