Idempotency
Network retries happen. The Idempotency-Key header lets you retry a createTask request without submitting duplicate jobs or double-spending credits.
How it works
Pass a stable Idempotency-Key header (up to 128 chars) on POST /api/v1/jobs/createTask:
curl -s https://nokai.studio/api/v1/jobs/createTask \
-H "Authorization: Bearer $NOKAI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-5678-thumbnail" \
-d '{
"model": "wan-i2v-480p",
"input": { "prompt": "..." }
}'If you send the same Idempotency-Key again before the job reaches a terminal state:
- You get the original
taskIdback. - No new job is created.
- No credits are reserved again.
Choosing a key
- Use a stable identifier -- e.g.
order-1234-thumbnail, notDate.now(). - Scope it to the logical request -- reusing the same key for different content silently returns the wrong job.
- Keep it unique per retry group -- once the job is terminal (
successorfail), a new submission with the same key will create a new job.
De-duplication window
De-duplication is active while the job is in a non-terminal state. After the job succeeds or fails, you can reuse the same key to start a fresh job.
Webhook idempotency
Webhook deliveries carry a stable event_id across retries. Use it to deduplicate on your receiver side -- see Concepts -> Webhooks.