Idempotency Keys in the Computer Use API: Never Double Charge
When you spin up a computer use agent with POST /v1/runs, every agent step costs $0.05. If your integration retries a request or suffers a network blip, you might accidentally trigger the same task twice. That means double the charge. The Coasty computer use API solves this with idempotency keys. The Idempotency-Key header makes writes safe to retry without creating duplicate runs or over-billing your wallet.
How it works
The idempotency key is an opaque string you send in the Idempotency-Key header with any write request that creates a resource. The server stores the key and returns the same run ID for subsequent requests that use the same key within a short window. This prevents duplicate task creation and ensures you are billed only once per logical operation. The key is not tied to a specific run ID. It is tied to the request payload and the server's retry behavior.
curl -X POST https://coasty.ai/v1/runs \
-H 'Content-Type: application/json' \
-H 'X-API-Key: $COASTY_API_KEY' \
-H 'Idempotency-Key: run-$(uuidgen)' \
-d '{
"machine_id": "vm-123",
"task": "Open Chrome and navigate to https://example.com",
"cua_version": "v3",
"max_steps": 100
}'Retry safe without duplicates
- ●Set Idempotency-Key on every POST /v1/runs request.
- ●If the request succeeds, the server returns the same run ID.
- ●If the request fails and retries, the server recognizes the key and does not create a new run.
- ●You are billed only for the first successful creation and subsequent successful agent steps.
- ●The key is not consumed after use. You can reuse it for the same logical operation on a different machine or task.
Always set Idempotency-Key on POST /v1/runs to prevent duplicate task runs and over-billing.
Where this beats brittle automation
Traditional automation relies on brittle selectors and API-only tools that often break when UI changes. The Coasty computer use API lets an agent see the screen and act like a human, which makes it more resilient. Idempotency keys ensure that even if your orchestrator retries a failed run, you do not pay for the same work twice. This combination of human-like agency and idempotent writes gives you reliable, cost-effective automation at scale.
Add Idempotency-Key to your POST /v1/runs calls today. Build robust task runners, workflows, and retries that never double-charge. Get your API key at https://coasty.ai/developers and start building with the computer use API.