POST leaves you unsure whether Tavrn processed it. Without a guard, retrying a retrieval request can open (and bill) a second retrieval. Send an Idempotency-Key header and the retry is safe: Tavrn runs the operation once and replays the same result for every retry.
How it works
EveryPOST on /v2 accepts an optional Idempotency-Key header: an opaque string of 1-255 characters that you generate per operation (a UUID v4 is recommended). Tavrn stores the first outcome for that key and compares each later request against it.
Rules:
- Keys are scoped to your organization, so a retry still replays after you rotate your API key.
- Keys are kept for 24 hours. A key reused after that runs as a new request.
2xxand4xxoutcomes are stored and replayed (a replayed400is the same400).5xxoutcomes are not.- JSON key order does not matter; any other change to the body counts as a different payload.
- Requests without the header behave exactly as before. The header is only honoured on
POST; it is ignored onGET,PATCHandDELETE.
201, the same id and Idempotent-Replayed: true.
Idempotency vs duplicate detection
These are two different protections:Idempotency-Keyis about your retry: the same request, sent again, produces one result. It is exact, deterministic and needs the header.409 duplicate_request_detectedis about your data: a new retrieval for a patient and facility that already has an active one is refused unless you passallow_duplicate: true. It is a heuristic over the request content and applies whether or not you send anIdempotency-Key.
Idempotency-Key never trips duplicate detection, because the operation only runs once.