Engineering

Idempotency Keys in the Computer Use API: Never Double Charge

Sophia Martinez||5 min
Ctrl+S

Task runs in the computer use API cost $0.05 per agent step. When your workflow retries a task, retries a workflow, or retries a workflow step, the same request can hit the server multiple times. You do not want to pay for the same action twice. Idempotency-Key protects you from accidental double charges on reserve-and-replay operations.

How idempotency works in the computer use API

Idempotency-Key only applies to the 18 documented reserve-and-replay operations. When you send a request with an Idempotency-Key, the server checks if it has already processed an identical request with that key. If it has, it returns the same response without processing the request again. The server does not charge you again for that operation. If the key is new, the request is processed normally. You can safely retry failed requests by reusing the same key.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $COASTY_API_KEY" \
  -d '{
    "machine_id": "aws-eu-central-1-prod-001",
    "task": "Open Chrome, go to https://coasty.ai, and click the Pricing button",
    "max_steps": 30,
    "deadline_seconds": 300,
    "on_awaiting_human": "pause",
    "idempotency_key": "re-run-2025-06-18-12-34-56-789"
  }'

Which operations support idempotency

  • POST /v1/runs with idempotency_key protects against duplicate task runs
  • POST /v1/workflows with idempotency_key protects against duplicate workflow definitions
  • POST /v1/workflows/{id}/runs with idempotency_key protects against duplicate workflow executions
  • POST /v1/machines with idempotency_key protects against duplicate machine provisioning
  • POST /v1/ground with idempotency_key protects against duplicate grounding calls
  • POST /v1/sessions with idempotency_key protects against duplicate session creation

Use Idempotency-Key on reserve-and-replay requests. It does not prevent duplicate charges outside these 18 operations.

Where this beats brittle automation

Traditional automation relies on brittle selectors and API-only tools. If a selector breaks or an API endpoint changes, you must rewrite your code. The computer use API lets an agent see the screen and act like a human. This makes your workflows resilient to UI changes. When you retry a failed run with an idempotency key, you avoid double billing while the agent reattempts the task on the live UI. You can integrate task results directly into your billing system, whether on AWS or GCP, without worrying about duplicate charges.

Use Idempotency-Key on reserve-and-replay requests such as task runs, workflows, and machines to prevent duplicate charges. The computer use API lets you build robust agents that see the screen and act like a human, with precise control over billing and retries. Get a key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free