Skip to main content
Networks drop, requests time out, and agents re-run steps, so the same POST sometimes fires twice. An idempotency key makes that safe: a retry with the same key returns the original result instead of creating a duplicate.

Send an idempotency key

Pass an Idempotency-Key header on any create, with a unique value per logical operation. A UUID is a good default.
Retrying that exact request with the same key returns the original message instead of sending a second one.
The key can be up to 128 characters; a longer value is rejected with 400. A blank or whitespace-only header is treated as absent.

Header and body agree

Some creates also accept an idempotencyKey in the JSON body. Dairo reconciles the header and the body field before running the request: Set the key either way. A disagreement is always surfaced as an error, never resolved silently.

Where it applies

Dairo reconciles the Idempotency-Key header into the body on every request, and honors it on creates plus the action POSTs where a duplicate would be costly:
GET requests are always idempotent and need no key. DELETE and PATCH are naturally idempotent (deleting or setting the same state twice has the same effect), so they do not take an Idempotency-Key.

Reuse the key, keep the payload

A key identifies one specific operation, not a slot you can overwrite. On a message send, reusing a key with a different subject or to returns the original send unchanged, plus a warning (reason: "idempotency_key_reused_with_different_params"); your new content is not sent. To send genuinely different content, use a fresh key. Two habits keep this predictable:
  • Generate the key before the first attempt and reuse it across every retry of the same operation. A fresh key per attempt defeats the purpose, since each new key is a new operation.
  • Use a stable, unique value. A UUID is the simplest safe choice. If you key off your own data, make the value unique per intended operation, for example order-4815-welcome-email.
The SDKs retry transient failures for you; passing an idempotency key makes those retries duplicate-safe end to end.