Networks fail. A request can time out after the server has already done the work, so the question is always: is it safe to send again?
Reads, replaces and deletes
GET is always safe to repeat. PUT replaces a resource with what you send, so sending it again gives the same result. DELETE of something already deleted answers 404, which you can treat as done.
Creates
A POST that creates something (a Group, an action, a comment, a key) creates another one if you send it twice. After a timeout, read before you retry: list the resource and look for the one you meant to create, for example by its name or title.
Answers in a checklist
Answers to checklist items are written by the web app and the mobile apps, which a signed-in person uses; an API key cannot write them. Each answer write carries an Idempotency-Key header, so a retried write is applied once:
- The same key with the same body returns the first result again, with the header
idempotent-replayed: true. - The same key with a different body is refused with
409 conflict, anddetails[0].codeisidempotency_key_reused. - A write based on an older revision of the answer is not lost: the response says
conflict: true, so the person can choose which value to keep.
Every answer, retried or not, is recorded once in the audit log with its old and new value, who gave it and where it came from.
Backoff
Retry 429 after the Retry-After seconds, and 5xx or a timeout with growing delays (for example 1, 2, 4 and 8 seconds, with some randomness). Do not retry other 4xx: they will fail the same way.