Guide
Idempotency
Send an Idempotency-Key header to retry a request safely. If a request times out or the
connection drops, send it again with the same key. Medicus carries it out once and returns the
original response to every retry.
POST /transactional-api/create-note
Authorization: Bearer <token>
Idempotency-Key: 6f1c2a8e-4b7d-4e2a-9c3f-1d5e8b7a2c40
Content-Type: application/json
The header is optional and works on every Transactional API endpoint. Use it on any request that creates or changes something.
Choosing a key
- Use a new random value, such as a UUID, for each new request.
- Keep the same key for every retry of that request.
- A key is up to 255 characters.
- Keys are scoped to your application and the endpoint, so the same key on two different endpoints is two different requests.
What a retry gets back
| Situation | Response |
|---|---|
| First request with this key | Carried out as normal |
| Same key, same body, first request finished | The original status code and body, with an Idempotent-Replayed: true header |
| Same key, same body, first request still running | 409 with idempotency-key-in-progress. Wait and retry. |
| Same key, different body | 422 with idempotency-key-reused |
| Key empty or over 255 characters | 400 with invalid-idempotency-key |
A 5xx response isn't kept, so a retry after a server error is carried out again.
How long a key lasts
Medicus holds a key for 2 minutes from the first request. After that, a request with the same key is treated as new, so retry within that window.