Back to Blog
Engineering

Emily Watson6 min
Cmd+V

Running a computer use API agent can consume credits quickly. A failed network call, a retry loop, or a buggy client might resend a POST to /v1/runs or /v1/workflows. Without protection, each duplicate request is billed. Idempotency-Key addresses this by making the first request idempotent and discarding later identical requests.

How idempotency works in the Coasty Computer Use API

Idempotency is not a generic feature for every endpoint. It only applies to the 18 reserve-and-replay operations documented by Coasty. When you include an Idempotency-Key header on one of these requests, the server records the request body. If the same request arrives again with the same key, the server returns the original response instead of creating a new run or workflow. This ensures a deterministic outcome and prevents duplicate billing for the same intent.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: run-$(uuidgen)" \
  -d '{
    "machine_id": "vm-123",
    "task": "open chrome and navigate to cozy.ai",
    "cua_version": "v3",
    "max_steps": 100,
    "deadline_seconds": 600
  }'

Idempotent endpoints and reserve-and-replay operations

  • POST /v1/runs , provision a task run and bill $0.05 per agent step
  • POST /v1/workflows , create a versioned workflow DSL and bill $0.05 per task step
  • POST /v1/workflows/{id}/runs , run a workflow instance
  • POST /v1/workflows/runs , ad-hoc inline workflow execution
  • Idempotency-Key only affects these reserve-and-replay operations. Other endpoints ignore the header and process each request independently.

Idempotency-Key is for reserve-and-replay operations only; it cannot be retroactively added to an existing request.

Where this beats brittle automation

Traditional automation often relies on brittle selectors that break when UI elements shift. The Coasty computer use agent drives real desktops, browsers, and terminals by interpreting screenshots and acting like a human. When a selector fails, the agent can retry or adapt. Idempotency keeps the billing predictable even as the agent explores and adjusts. This makes the computer use API a reliable foundation for reproducible, expensive automation workloads.

Use Idempotency-Key on reserve-and-replay operations to guarantee each request is billed once. Build robust computer use agents that respect billing and avoid surprise charges. Get your API key and start building at https://coasty.ai/developers .

© 2026 Coasty

Backed byYCombinator