Idempotency
Network calls fail in the worst way: the request reaches the server, the response is lost, and your client has no idea whether the operation happened. Retrying blindly risks creating the resource twice. An idempotency key makes a retry safe — KnoxCall recognises the repeated key and replays the original outcome instead of performing the operation again. Send an idempotency key on any mutating request (POST, PUT, PATCH, DELETE). It is
ignored on safe GET requests, which are naturally idempotent.
Sending an idempotency key
Send a unique key per logical operation. A UUID is a good default.Generate a fresh key for each distinct operation, and reuse the same key only when
retrying that exact operation. Reusing one key for two genuinely different requests is an
error — see Reuse with a different body.
Replaying a stored response
The first request with a given key is processed normally and its response is stored. Any later request with the same key and the same body does not re-run the operation — KnoxCall replays the stored status code and body, and adds a header so you can tell it was a replay:Error semantics
Idempotency errors use the canonical error envelope.Still in progress → 409
If a request with the same key is still being processed when a retry arrives, the retry is
rejected with 409 and the request_in_progress type. Wait briefly and retry — the original
is on its way to completion.
Reuse with a different body → 422
If you reuse a key that was already used for a different request body, KnoxCall rejects the
new request with 422 and the idempotency_key_reuse type rather than silently doing the
wrong thing. This is the API’s only 422. The fix is to use a fresh key for the new operation.
Malformed key → 400
A key that is malformed or too long is rejected with 400 and the invalid_idempotency_key
type before any work is done.
Summary
Recommended pattern
- Generate one key per logical operation (a UUID) and hold onto it for the duration of your retries.
- Send it as
X-Idempotency-Keyon the mutating request. - On a network error, timeout, or
5xx, retry with the same key — you will either perform the operation once or replay its stored result. - On
409 request_in_progress, wait briefly and retry the same key. - Never reuse a key for a different operation; if the body must change, mint a new key.
What’s Next?
Errors
The canonical error envelope and the full type → status table.
Rate limits
Headers,
Retry-After, and backoff guidance for 429 responses.API Overview
Base URLs, response envelope, pagination, and quick examples.
Authentication
OAuth 2.1 + DPoP, CLI login, and API key types.