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 anIdempotency-Key header on any create, with a unique value per logical operation.
A UUID is a good default.
400. A blank or
whitespace-only header is treated as absent.
Header and body agree
Some creates also accept anidempotencyKey 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 theIdempotency-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 differentsubject 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.