Webhook events
nokai.studio 触发四种事件类型。所有事件使用相同的信封;仅 data 结构不同。
完整的 payload 结构见 Webhooks -> Payloads,签名校验见 Webhooks -> Signing。
Envelope(所有事件)
{
"api_version": "v1",
"event_id": "uuid",
"event": "job.completed",
"customer_id": "cust_uuid",
"created_at": "2026-05-29T12:00:00Z",
"data": { ... }
}job.completed
当生成 job 达到 success 时触发。
{
"data": {
"taskId": "task_01abc...",
"model": "wan-i2v-480p",
"state": "success",
"resultJson": "{\"resultUrls\":[\"https://nokai.studio/f/Qm9XvT2sLp8Zr4Kc7Nw1Jd6Hy3Ga5Ue0Ft9Bo2Mi8Sx4Vk7Rl1Pq6Dz3Cn5Wj0Ey/output.mp4\"]}",
"creditsConsumed": 10,
"completeTime": 1748563200
}
}| 字段 | 类型 | 备注 |
|---|---|---|
taskId | string | |
model | string | |
state | "success" | 此事件始终为 "success"。 |
resultJson | string | JSON 编码的 { resultUrls: string[] }。请解析它。 |
creditsConsumed | integer | 此 job 扣除的额度。 |
completeTime | integer | Unix 时间戳(秒)。 |
job.failed
当生成 job 达到 fail(所有重试耗尽后)时触发。
{
"data": {
"taskId": "task_01abc...",
"model": "wan-i2v-480p",
"state": "fail",
"failCode": "CONTENT_POLICY",
"failMsg": "Prompt violates content policy"
}
}| 字段 | 类型 | 备注 |
|---|---|---|
taskId | string | |
model | string | |
state | "fail" | 此事件始终为 "fail"。 |
failCode | string | 机器可读的失败原因。 |
failMsg | string | 人类可读的失败原因。 |
credits.low_balance
当账户余额低于配置的低余额阈值时触发。
{
"data": {
"customerId": "cust_uuid",
"balanceUsdMicro": 950000,
"thresholdUsdMicro": 1000000
}
}balanceUsdMicro / 1_000_000 = 以 USD 计的余额。
credits.topped_up
当一笔 Stripe 支付完成且额度已添加到账户时触发。
{
"data": {
"customerId": "cust_uuid",
"balanceUsdMicro": 25950000,
"addedUsdMicro": 25000000,
"stripeChargeId": "ch_..."
}
}| 字段 | 类型 | 备注 |
|---|---|---|
customerId | string | |
balanceUsdMicro | integer | 充值后的新余额。 |
addedUsdMicro | integer | 添加的金额。 |
stripeChargeId | string | 用于对账的 Stripe charge ID。 |