Webhook
タスクが完了、失敗、キャンセルされたときにPOSTリクエストを受け取ります。
パス callback_url タスクを作成する際、API はタスクがターミナルステータスに達した後、タスクをそのタスクに投稿します。completed, failed または canceled) 体はまさにその形である GET /api/v1/tasks/:id returns — one handler serves both.
Delivery is attempted twice with an 8-second timeout and is best-effort. Treat the webhook as a wake-up signal: on receipt (and as a fallback if it never arrives), confirm the state by fetching GET /api/v1/tasks/:id. 返信は署名されていません。再フェッチすることが検証です。
URLはHTTPSで公開アクセス可能である必要があります。localhostおよびプライベートネットワークアドレスは拒否されます。 サンドボックス(テストキー)のタスクは、作成から約35秒後に同じコールバックを起動します。これにより、無料でハンドラーを開発できます。
タスクを A で作成する callback_urlPOST を処理してください。つまり、本体は同じ形状です GET /api/v1/tasks/:id戻り値:
// e.g. a Next.js / TanStack Start route handler
export async function POST(request) {
const task = await request.json();
if (task.status === 'completed') {
const urls = task.data.results; // download / store promptly
}
if (task.status === 'failed') {
console.error(task.failed_reason); // Check task.billing_status for the billing state.
}
// Recommended: confirm via GET /api/v1/tasks/:id before acting.
return new Response(null, { status: 200 });
}2xxにすばやく返信してください。非同期的に重い作業をしてください。
プライベートな結果リンクは秘密にしてください。 リンクが期限切れになった場合は、タスクを新たに入力して問い合わせてください。 後回しに却下された結果は、今後は入手できなくなります。 タスクの現在のステータスを照会してください。レビューの変更は、別の端末のWebhookをトリガーしません。