API referenceError code index409idempotency_key_reused

idempotency_key_reused

The message text is shown in the example below.

⚠️
Preview — this feature is being built; the design below is the spec. In the public error catalog, but today only the private mobile conversation routes return it.
HTTP status409
typeconflict_error
Retry?No, not unchanged
StatusNot live / provisional
Extra fieldsnone

When it happens

The same Idempotency-Key was sent within 24 hours with a different body.

Example

{
  "error": {
    "type": "conflict_error",
    "code": "idempotency_key_reused",
    "message": "This Idempotency-Key was already used with a different request body. Use a new key for a new request.",
    "param": null,
    "request_id": "req_6f1c2a9e0b7d4c3a8e5f1b2d"
  }
}

How to fix it

  • Generate a new key for every logically new operation; reuse a key only when retrying the identical request.

Detect it in code

err = resp.json().get("error", {})
if resp.status_code == 409 and err.get("code") == "idempotency_key_reused":
    log.warning("%s (%s)", err["message"], err["request_id"])  # fix the request; do not retry unchanged
Was this page helpful?