Some Alterscope endpoints trigger side effects you don’t want to happen twice — submitting an execution step, running a billed simulation, recording an autonomous decision. If the network drops your connection after the server acted but before you saw the response, a naive retry could double-submit. Idempotency solves this. Send a uniqueDocumentation Index
Fetch the complete documentation index at: https://docs.alterscope.org/llms.txt
Use this file to discover all available pages before exploring further.
X-Idempotency-Key on each such request, and the API guarantees that retrying with the same key replays the original response instead of re-running the work.
Idempotency is required on mutation, simulator, and execution
POST endpoints. A request to one of these without an X-Idempotency-Key header returns 400. GET requests don’t need it — they’re already safe to repeat.Sending the key
Add the header to every protectedPOST:
X-Decision-Trace-ID, alongside the idempotency key; a missing trace ID returns 400. See Errors for the full status mapping.
Generating a key
A key must be unique to the logical operation you’re performing. Two strategies work:- Random UUID v4 — generate a fresh key per operation and reuse the same key across retries of that one operation. This is the simplest correct approach.
- Stable business key — derive the key deterministically from your own request identity (for example, an order ID or a step ID), so independent processes retrying the same logical action converge on the same key.
The replay window
Once a request completes successfully, the API caches its response for 24 hours. Any retry within that window that reuses the same key (and body) gets the original response back, byte-for-byte, with a header signalling the replay:X-Idempotency-Replayed: true if you need to distinguish a fresh result from a cached one.
Two details worth knowing:
- Only successful (2xx) responses are cached. If the original request failed (any non-2xx status), the key is released — a retry with the same key re-runs the operation normally. You don’t need to mint a new key after a failure.
- The cache is request-body sensitive. Same key, different body → no replay (see the warning above).
In-flight requests
If you fire a second request with the same key while the first is still being processed, the API doesn’t run it twice and doesn’t block waiting. It returns409 Conflict immediately with a Retry-After header:
X-Idempotency-Replayed: true) rather than re-executing.
Worked example
A client submits an execution step, the connection drops before the response arrives, and the client retries:First attempt
Client
POSTs with X-Idempotency-Key: 3f8a1c2e-.... The server runs the handler, performs the side effect, and would return 200 — but the connection drops and the client never sees it. The successful response is now cached against the key for 24 hours.Retry (same key)
The client retries the identical request with the same The side effect ran exactly once. The client sees the original result.
X-Idempotency-Key. The server finds the cached response and replays it:Next steps
Errors
Status codes and error envelope for failed requests.
Rate limits
Per-tier request and quota limits.