Safe retries
A network can drop an answer after Paie has made the change. If you send the change again, it must not happen twice. So every change sends an Idempotency-Key header.
How it works
Section titled “How it works”- Make a new key for each change, like a UUID. Keep it with the change.
- Send it as
Idempotency-Key: 8e0c…on the call. - If you get no answer, or a
5xx, send the same call again with the same key.
Paie remembers each key for 24 hours:
- Done before: Paie answers what it answered the first time, adds
Idempotent-Replayed: true, and changes nothing. - Still running:
409 in_progress. Wait a moment and try again. - Sent with a different request:
409 idempotency_mismatch. Use a new key for a new change. - Refused before (a
4xx): nothing was changed, so the key is free. Fix the request and send it again.
A change with no Idempotency-Key is refused with bad_request.