How do I retry a Cartroute call safely?
Send an Idempotency-Key header on metered calls. If the same key is used again for the same operation within 24 hours, Cartroute returns the first response unchanged, with idempotent_replay: true, and charges nothing. That makes it safe to retry after a timeout without paying twice.
How do I use an idempotency key?
curl "https://cart-route.com/api/v1/search?q=robot+vacuum" \ -H "Authorization: Bearer $CARTROUTE_API_KEY" \ -H "Idempotency-Key: 4b1d7c1e-3f2a-4a4e-9a57-1b1a2f6c0e91"
Use a fresh random value (a UUID) per logical request, and reuse it only when retrying that same request. Keys are scoped to your account and the operation, up to 200 characters.
Which failures should be retried?
| Outcome | Retry? | How |
|---|---|---|
| Network error or timeout | Yes | Same request, same Idempotency-Key. |
429 rate_limited | Yes | After Retry-After seconds. |
500 internal_error, 502, 503, 504 | Yes | Exponential backoff: 1 s, 2 s, 4 s, up to 3 attempts. |
401, 402, 403, 404 | No | The answer will not change. |
422 | Only after fixing | Change the parameter named in param. |
What does a replayed response look like?
Identical to the original body, plus "idempotent_replay": true and "credits": {"charged": 0, "remaining": ...} showing the current balance.
Does the MCP server support idempotency?
Not per call. MCP clients do not send an equivalent key, so each successful tools/call is charged. Agents that need retry-safety for expensive loops should call the REST API.