Summary
After the next qURL prod release, the API will support the `Idempotency-Key` header end-to-end on state-mutating endpoints — so a retried request with the same key returns the original response instead of creating a duplicate.
This SDK should generate and forward that header automatically so users do not have to think about it.
Why
`#19` ("POST retries on network errors can duplicate items (batch_create especially)") is the user-facing symptom. Today, a transient 5xx or socket reset on `client.create()` / `batch_create()` / mint flows can produce duplicate resources after the SDK retries — because each retry is a fresh request from the server's perspective. With idempotency-key forwarding in place, the server collapses retries onto the original response.
Proposed surface
- Auto-generate a UUIDv7 `Idempotency-Key` per outbound POST/PUT/PATCH (read-only methods do not need it).
- Reuse the same key across retries of the same logical call — do NOT regenerate inside the retry loop, otherwise the server sees N independent writes.
- User override via a per-call option (e.g. `idempotency_key=...` on the public methods) for callers that want to tie idempotency to their own request ID (e.g. an upstream job ID) instead of an SDK-generated UUID.
- Apply to both the sync (`client.py`) and async (`async_client.py`) clients.
- Documentation: brief README section explaining what the SDK now does on retries, and how to override; docstrings on the affected methods.
Definition of done
Sequencing
Gate landing this on the qURL prod release that ships server-side `Idempotency-Key` support on `POST /v1/api-keys`. The generic middleware on other POST endpoints is already live, so the SDK can begin sending the header sooner — but holding until the API-key path is also covered keeps the rollout coherent.
Summary
After the next qURL prod release, the API will support the `Idempotency-Key` header end-to-end on state-mutating endpoints — so a retried request with the same key returns the original response instead of creating a duplicate.
This SDK should generate and forward that header automatically so users do not have to think about it.
Why
`#19` ("POST retries on network errors can duplicate items (batch_create especially)") is the user-facing symptom. Today, a transient 5xx or socket reset on `client.create()` / `batch_create()` / mint flows can produce duplicate resources after the SDK retries — because each retry is a fresh request from the server's perspective. With idempotency-key forwarding in place, the server collapses retries onto the original response.
Proposed surface
Definition of done
Sequencing
Gate landing this on the qURL prod release that ships server-side `Idempotency-Key` support on `POST /v1/api-keys`. The generic middleware on other POST endpoints is already live, so the SDK can begin sending the header sooner — but holding until the API-key path is also covered keeps the rollout coherent.