Skip to content
Developers

Idempotency and retries

Make a write safe to retry with Idempotency-Key, and which failures to retry.

Idempotency-Key

Writes whose double execution would cost money or send a message accept an Idempotency-Key header (up to 255 characters; longer is a 400, never cut).

SituationAnswer
First call with a keyRuns. A success is stored for 24 hours, and so is a 502 creation_status_unknown (it may have gone); any other failure releases the key.
Same key, same body, after it finishedThe stored answer, with Idempotent-Replayed: true
Same key, still running409 idempotency_conflict + Retry-After
Same key, different body422 idempotency_key_reused
After 24 hoursRuns as a new request

An automation sends each step with its own key; one key never covers a whole run. Keys are scoped to your brand and the operation. On the MCP server every write tool takes an optional idempotencyKey argument; leave it out and one is derived from the call.

When to retry

  • Retry 408, 429, 5xx and network errors. Never retry any other 4xx: the answer will not change.
  • Always wait the Retry-After seconds. On a 429 without it, back off exponentially.
  • Never retry a POST that timed out on your side with a new key. It may have completed. Retry it with the SAME Idempotency-Key; a replay answers with the first result.
  • 502 creation_status_unknown means a create may or may not have happened at the provider. Read before you retry.
  • 400 platform_not_supported and 412 platform_scope_missing never succeed as they are: change the channel, or reconnect the account with the missing permission.
  • Send one X-Request-Id per logical call and reuse it on every attempt.

How it behaves

  • The key is the retry's identity: the same key and body always return the first result for 24 hours.
  • A refusal (a 4xx) releases the key, so the same key can run again once you fix the request.
  • Keys belong to your brand and the operation. Another brand, or another operation, never sees them.

If it fails

AnswerCauseFix
409 idempotency_conflictThe same key is still runningWait Retry-After seconds and retry with the same key.
422 idempotency_key_reusedThe key was used with a different bodyUse a new key for a different request.
502 creation_status_unknownThe platform may or may not have done the writeRead the resource, or wait for its webhook, before deciding. Never send it again with a new key.
400 on the keyThe key is longer than 255 charactersShorten it. It is never cut for you.
429 or 503Too many requests, or busyWait Retry-After and retry with the same key.

Try it on real customer chats

Connect Instagram, WhatsApp or any other channel and start replying today.