Webhook
Tạo endpoint
Đăng ký một URL để nhận sự kiện. Trả về secret ký, chỉ một lần.
https://api.sangtao.ai/v2/webhooksXác thực
X-Api-Keystring · headerbắt buộcAPI key của bạn, tạo ở trang API key trong tài khoản.
Sự kiện, chữ ký và cách thử lại: Webhook.
Body
urlstringbắt buộcURL https công khai, cổng 443, không kèm tài khoản / mật khẩu. Tối đa 500 ký tự
eventsstring[]bắt buộcCác loại sự kiện muốn nhận, hoặc ["*"] để nhận tất cả
Giá trị có thể:
*image.completedimage.failedvideo.completedvideo.failedpost.publishedpost.failedsocial_account.needs_attentiondescriptionstringGhi chú cho bạn. Tối đa 200 ký tự
Response
idstringbắt buộcMã endpoint, whk_…
urlstringbắt buộcNơi nhận sự kiện
eventsstring[]bắt buộcCác loại sự kiện endpoint nhận. ["*"] là tất cả
descriptionstring | nullGhi chú của bạn
enabledbooleanbắt buộcCó đang gửi sự kiện tới endpoint không
statusstringbắt buộcdisabled_failing: tự tắt sau 3 ngày giao hỏng liên tục
Giá trị có thể:
activedisableddisabled_failingcreatedAtstringbắt buộcLúc tạo (ISO 8601, UTC). Endpoint chỉ nhận sự kiện xảy ra từ lúc này
lastDeliveryAtstring | nullLần gần nhất thử giao tới endpoint
lastSuccessAtstring | nullLần gần nhất endpoint trả 2xx
lastFailureAtstring | nullLần gần nhất giao hỏng
secretstringbắt buộcwhsec_… — chỉ hiện ở response này. Hãy lưu lại: dùng để kiểm chữ ký mọi lần giao
Mã lỗi
| Mã | errorCode | Khi nào |
|---|---|---|
| 422 | INVALID_WEBHOOK_URL | url không phải URL https công khai cổng 443, hoặc có kèm tài khoản / mật khẩu |
| 422 | INVALID_WEBHOOK_EVENT | events trống hoặc có loại không tồn tại — các loại hợp lệ ở details[0].params.allowed |
| 422 | VALIDATION_ERROR | description dài quá 200 ký tự |
| 422 | WEBHOOK_LIMIT_REACHED | Bạn đã có 10 endpoint |
/webhookscurl -X POST "https://api.sangtao.ai/v2/webhooks" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/sangtao",
"events": [
"image.completed",
"image.failed"
],
"description": "Production"
}'{
"success": true,
"data": {
"id": "whk_4nP8rT2xK",
"url": "https://example.com/webhooks/sangtao",
"events": [
"image.completed",
"image.failed"
],
"description": "Production",
"enabled": true,
"status": "active",
"createdAt": "2026-11-10T08:00:00Z",
"lastDeliveryAt": null,
"lastSuccessAt": null,
"lastFailureAt": null,
"secret": "whsec_Zx3…"
}
}/webhookscurl -X POST "https://api.sangtao.ai/v2/webhooks" \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/sangtao",
"events": [
"image.completed",
"image.failed"
],
"description": "Production"
}'{
"success": true,
"data": {
"id": "whk_4nP8rT2xK",
"url": "https://example.com/webhooks/sangtao",
"events": [
"image.completed",
"image.failed"
],
"description": "Production",
"enabled": true,
"status": "active",
"createdAt": "2026-11-10T08:00:00Z",
"lastDeliveryAt": null,
"lastSuccessAt": null,
"lastFailureAt": null,
"secret": "whsec_Zx3…"
}
}