Back to Blog
Engineering

Sarah Chen6 min
⇧+Enter

When you push a task run or a workflow step, the Computer Use API charges immediately. If you retry a request or replay it from logs, you might double-bill. Idempotency keys solve this by ensuring the API treats an exact duplicate as a single successful operation. This guide shows how reserve-and-replay works with the real endpoints and how to keep your wallet safe.

How idempotency works

The API supports idempotency keys only on the 18 documented reserve-and-replay operations. When you include an Idempotency-Key header on an original request, the API stores it in its idempotency store. Subsequent calls with the same key are treated as a replay of the first request. The response is identical, and no additional credits are deducted. If you omit the key, each request is billed independently. This behavior is enforced server-side and does not require client-side state tracking.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "Authorization: Bearer $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: run-20250618-001" \
  -d '{
    "machine_id": "dev-vm-01",
    "task": "install python3 and pip",
    "cua_version": "v3",
    "max_steps": 30,
    "deadline_seconds": 3600
  }'

If the same Idempotency-Key is sent again with identical parameters, the API returns the original run status without charging again.

Key endpoints and operations

  • POST /v1/runs - Reserve a task run with an Idempotency-Key to prevent duplicate billing.
  • POST /v1/workflows - Reserve a workflow with an Idempotency-Key for each top-level workflow.
  • POST /v1/workflows/{id}/runs - Reserve a workflow run with an Idempotency-Key.
  • POST /v1/workflows/runs - Reserve an ad-hoc inline workflow with an Idempotency-Key.
  • The key must be a stable string that uniquely identifies the logical operation. Reusing the same key on different parameters is undefined and may cause unexpected behavior.

Include Idempotency-Key on every reserve-and-replay operation to ensure each logical action is billed once.

Where this beats brittle automation

API-only tools rely on fragile selectors or brittle webhook parsing. A single UI change can break your automation. The Computer Use API lets you describe a task in natural language. The agent observes the screen with vision and acts like a human, adapting to layout changes without selector updates. Combine this with idempotency keys: your agents can retry failed steps, log actions, and replay them safely without inflating your bill.

Build production-grade asynchronous agents with the Coasty Computer Use API. Use idempotency keys on reserve and replay operations to keep your costs predictable. Get your API key at https://coasty.ai/developers and start building smarter automation.

© 2026 Coasty

Backed byYCombinator