API reference

Error code: idempotency_key_malformed

idempotency_key_malformed returns HTTP 400 with type: invalid_request_error. The idempotency key was not a valid format. When it is about one field, error.param names Idempotency-Key. Branch on the code and apply the fix below.

2 min read

400HTTP status
idempotency_key_malformederror.code
FixHandling

What triggers it

The idempotency key was not a valid format. An empty key, or one over 255 characters.

Example response

{
  "error": {
    "type": "invalid_request_error",
    "code": "idempotency_key_malformed",
    "message": "The idempotency key was not a valid format.",
    "param": "Idempotency-Key"
  }
}

How to fix it

Send a non-empty key up to 255 chars — a UUID is ideal.

This is deterministic; fix the cause before resending. See the error code catalogue for related codes.

In practice

In a well-built client, idempotency_key_malformed is handled by branching on error.code rather than on the human error.message, which may be reworded over time. The HTTP status (400) gives the broad invalid_request_error class; the code gives the specifics; and, on field errors, error.param pinpoints the input to fix.

This code is deterministic — retrying the identical request reproduces it — so keep it out of your retry path and instead map it to a clear, actionable message. See Map errors to user-facing messages and Read the error envelope for the pattern.

Frequently asked questions

Is idempotency_key_malformed safe to retry?

No. Retrying the identical request reproduces the identical error. Fix the cause first.

Will this code ever change?

No. Error codes are stable contract; only the human message may be reworded.

Do I branch on the code or the HTTP status?

Both — status for retry-or-not, code for the specific behaviour. See the error envelope.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.