Idempotency
Write operations (POST, PUT, PATCH) accept anIdempotency-Key header to
prevent duplicate actions when agents or integrations retry requests.
How It Works
- Generate a unique key (UUID recommended) for each logical operation
- Send it in the
Idempotency-Keyheader - If the same key is sent again within 24 hours with the same body, the original response is replayed without re-executing the operation
- If the same key is sent with a different body, you get
409 Conflict
Example
Behavior
| Scenario | Result |
|---|---|
| New key | Execute normally, cache response |
| Same key + same body | Replay cached response (HTTP status preserved) |
| Same key + different body | 409 Conflict |
| Key expires (24h) | Treated as new key |
| GET/DELETE requests | Header ignored (these are naturally idempotent) |
Key Requirements
- Minimum 8 characters, maximum 256 characters
- Must be unique per logical operation
- UUID v4 recommended:
crypto.randomUUID()
Best Practices
- Always include
Idempotency-Keyon mutation endpoints - Store the key alongside your operation log for debugging
- Use a deterministic key (e.g.,
${orderId}-assign-${staffId}) when retrying the same logical operation