Idempotency Keys in the Computer Use API: Never Double Charge
When you build a computer use agent over a stateful trajectory API, a network blip or a retry can cause the same action to be applied twice. That means paying for the same step twice. The Coasty Computer Use API solves this with idempotency keys for a specific set of reserve-and-replay operations. You get replay safety without changing your workflow logic, and you never see an unexpected balance deduction.
How it works
Idempotency keys are part of the request payload. The API uses the Idempotency-Key header to detect duplicate requests. If a request with the same key is received again, the server returns the original response instead of executing the operation again. This applies only to the 18 documented reserve-and-replay operations. Other endpoints, like GET /v1/runs or POST /v1/ground, do not support idempotency. Idempotency does not retroactively apply to existing transactions, and it cannot be added after the fact.
curl -X POST https://coasty.ai/v1/runs \
-H "Content-Type: application/json" \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{
"machine_id": "vm-12345",
"task": "Install a new browser extension",
"cua_version": "v3",
"max_steps": 50,
"deadline_seconds": 600
}'What is covered by idempotency
- ●The 18 documented reserve-and-replay operations that support Idempotency-Key.
- ●Requests that fail on the first attempt and are retried with the same key.
- ●Requests that are idempotent but are not part of the reserve-and-replay set.
- ●Requests that include Idempotency-Key but are not in the supported operations return a 400 Bad Request with an error code.
Include an Idempotency-Key when retrying failed reserve-and-replay operations.
Where this beats brittle automation
Traditional automation relies on brittle selectors and assumes a single request-response path. A network hiccup can cause a click or form submission to fire twice. With a computer use agent, you still want replay safety for stateful trajectories. Idempotency keys let you retry failed requests without fear of duplicate charges. You keep the human-like behavior of driving the desktop while maintaining financial safety. Webhook signatures (Coasty-Signature) provide additional validation for server-driven events.
Add idempotency keys to your retry logic for reserve-and-replay operations. This ensures you never pay twice when your agent encounters network issues. Build more resilient computer use agents at https://coasty.ai/developers.