Back to Blog
Tutorial

Lisa Chen5 min
+Enter

Task runs in the Coasty computer use API are billed per agent step at $0.05. A flaky network, a client crash, or a retry loop can accidentally trigger the same run multiple times, leading to unexpected costs. Idempotency-Key provides replay safety for the exact 18 documented reserve-and-replay operations when present on the original request. It cannot be added retroactively.

How it works

When you POST /v1/runs with an Idempotency-Key header, the server checks for an existing run with that key. If found, the server returns the cached response instead of starting a new run. If not found, it processes the request and stores the result keyed by the Idempotency-Key. This guarantees that the same key produces the same outcome and the same billing record for the client.

bash
#!/bin/bash
# Example using curl to create a task run with idempotency
export COASTY_API_KEY="${COASTY_API_KEY}"

curl -i -s -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: e7c61f3e-8a2c-4f4b-9e1c-05b34a2d8a8e" \
  -d '{
    "machine_id": "cloud-vm-123",
    "task": "Install Python 3.12 and run pip install requests",
    "cua_version": "v4",
    "max_steps": 50,
    "deadline_seconds": 600
  }' | jq -r '.id.status.status_message'

When idempotency applies

  • Idempotency-Key is only honored on the exact 18 reserve-and-replay operations documented in the API docs.
  • Task runs POST /v1/runs are covered when the key is present on the request.
  • Workflows POST /v1/workflows and workflow runs are covered when the key is present.
  • Not honored on individual step actions from /v1/predict or /v1/sessions/{id}/predict.
  • Not honored on GET requests or other non-reserve endpoints.
  • Idempotency-Key cannot be added retroactively to a completed run.

Use Idempotency-Key only on reserve-and-replay operations like POST /v1/runs and POST /v1/workflows.

Where this beats brittle automation

Traditional automation relies on brittle selectors and hardcoded URLs. If a page layout changes, the automation breaks. The computer use agent observes the screen, understands context, and acts like a human. Idempotency-Key adds a strong guard against duplicate runs caused by retries, network hiccups, or multiple client instances, ensuring you pay for work that actually completes.

Add Idempotency-Key to your reserve-and-replay POST requests to prevent duplicate runs and unexpected charges in your computer use agent. Get your API key at https://coasty.ai/developers and start building reliable automation.

© 2026 Coasty

Backed byYCombinator