Idempotency Keys in the Computer Use API: Never Double Charge
Automation workflows often retry on network hiccups or transient errors. If each retry triggers a fresh agent step, you can burn through credits fast. The Coasty Computer Use API solves this with idempotency keys for all write endpoints. A single key guarantees that retries produce the same result without creating duplicate tasks, sessions, or workflows. This post shows how to use idempotency keys to keep your wallet safe while building robust computer use agents.
How idempotency works in the Computer Use API
All write operations expose an Idempotency-Key header. The server stores the key and ignores subsequent requests that match an ongoing or completed operation. This prevents duplicate billing for the same work. The API treats each key as unique per endpoint, so a key used for a task run does not apply to a session or workflow creation. The server returns a 409 Conflict response if the request is a duplicate. Otherwise, it processes the write and returns a 201 Created or 200 OK with the normal payload. Idempotency applies to these endpoints POST /v1/runs, POST /v1/workflows, POST /v1/sessions, and POST /v1/machines. Each of these operations can cost credits, so proper idempotency is essential for predictable billing.
curl -X POST https://coasty.ai/v1/runs \
-H 'Content-Type: application/json' \
-H 'X-API-Key: $COASTY_API_KEY' \
-d '{
"machine_id": "m_abc123",
"task": "open chrome and navigate to coasty.ai",
"cua_version": "v3",
"instructions": "use the default browser",
"max_steps": 30,
"deadline_seconds": 300,
"on_awaiting_human": "pause",
"webhook_url": "https://your-server.com/webhook"
}' \
-H 'Idempotency-Key: run-unique-123'Billed operations and credit usage
- ●Task runs charge $0.05 per agent step, billed after each step completes successfully.
- ●POST /v1/runs idempotency prevents duplicate runs from incurring multiple step charges.
- ●Workflows are billed $0.05 per task step executed, with idempotency protecting retries.
- ●Session creation is $0.10 and not tied to step counts, but still benefits from idempotency to avoid duplicate sessions.
- ●Machines provision a cloud VM; idempotency on POST /v1/machines prevents multiple VMs from being created for the same key.
Use the same Idempotency-Key on retries to guarantee at most one charge for each unit of work.
Where this beats brittle automation
Traditional automation relies on fragile selectors, hard-coded coordinates, and brittle API integrations. A change in UI layout or DOM structure can break a script overnight. The Coasty Computer Use API lets you specify high-level instructions like "search for a file and open it" and the agent interprets the screen. If a step fails, you can retry with an idempotency key without fear of a second charge. This approach shifts cost and complexity from fragile selectors to reliable, idempotent retries that only pay for real work completed by the agent.
Build resilient computer use workflows that only charge for real work. Use idempotency keys on all write endpoints to prevent duplicate billing. Ready to start? Get a key at https://coasty.ai/developers and start automating with the Computer Use API.