Idempotency
All AstroWay API endpoints are naturally idempotent: same input always produces same output, no side effects (except credit consumption and usage logging).
This means retrying on network errors is safe. But to ensure a retry doesn’t charge credits twice, pass an Idempotency-Key header.
How to use
Section titled “How to use”POST /v1/chart HTTP/1.1X-Api-Key: aw_live_...Idempotency-Key: 01HXY2A7ZM0ABCDEFContent-Type: application/json
{ "date": "1990-07-14", "time": "14:30:00", ... }Idempotency-Key — arbitrary string up to 64 characters, unique per logical operation. Recommended: ULID or UUID v4.
Guarantees
Section titled “Guarantees”- For 24 hours after the first request with a given key, repeat requests with the same key return the same response without recalculation and without charging credits.
- If the request body differs from the original — returns
409 Conflictwith codeidempotency_key_reuse. - After 24 hours the key is forgotten; a new request with the same key is treated as a normal new request.
When you need it
Section titled “When you need it”- In webhook handlers where retries come from an external system (e.g. a payment provider or CRM sending events you parse and use for a calculation)
- In background jobs where retry is standard behavior on failures
- In CI/CD pipelines where a test may run multiple times
For normal “user clicks a button → show a chart” flows, idempotency isn’t needed — the user sees the result anyway, repeat clicks are rare.
When not to use
Section titled “When not to use”- Don’t set the key to save credits on identical requests — use
X-Cachefor that (free, 5 minutes) - Don’t generate the key from
hash(body)— you’d lose the default Idempotency-Key behavior (repeat409on body mismatch)
Was this helpful?
Thanks for the feedback.