Guides · Guide

Idempotency and retries

How to make a request safe to send twice, and how to retry without making a mess.

Updated 2 December 2026

The problem

Networks fail in the middle. You send a request, the connection drops, and you do not know whether it arrived. If you send it again and it had arrived, you have asked for two databases. Idempotency removes the doubt: you attach a key, and sending the same key again returns the original instead of making a second one.

The Idempotency-Key header

POST /requests requires an Idempotency-Key header of 8 to 120 characters.

CaseWhat happens
A new key201 Created, and the request is made.
A key already used in your organisation200 OK with the original request and the header Idempotent-Replayed: true. Nothing new is made.
A missing or too short key400 idempotency_key_required.
Important

The key identifies the intent, not the body. If you reuse a key with a different body, you get the first request back, not an error and not a new request. Use a new key for a new intent.

Keys are unique across your whole organisation, not per token, and they last as long as the request does.

Choosing a key

Build the key from what identifies the intent, so a retry or a rerun produces the same key:

  • A pipeline run and the thing it makes: gha-8231904552-orders-db.
  • A release and a service: release-2026-12-02-orders-db.
  • A tool's arguments: provision-orders-databases.create-orders-db.

A random key (a UUID) is also fine when you want every call to be a separate intent, but then a retry after a crash is a new request unless you saved the key before sending.

Data protection

A key is stored, shown in the console and written to logs. Never build it from personal data: no names, email addresses, account numbers or anything that identifies a person.

What to retry

ResponseRetry?How
Network error or timeoutYes, if it is a GET or a POST with a keyBack off, then send the same request again.
429 rate_limitedYesWait for Retry-After.
500, 502, 503, 504Yes, if it is a GET or a POST with a keyBack off.
400, 401, 403, 404, 409NoThe request will not work as sent. Fix it.
A POST without a key (/projects)NoCheck what exists with a GET, then decide.

Use exponential backoff with jitter: wait a random time up to 0.5 s, then 1 s, 2 s, 4 s, capped at 30 s, giving up after about four tries. Jitter stops many clients retrying in step. When a Retry-After header is present, wait at least that long. The reference clients do all of this.

The one rule

Never retry a POST that has no idempotency key after a timeout. You do not know whether it was made.

This page as MarkdownReport a problem with this pageOlympus Group Holdings, Inc.