Idempotency Keys in the Computer Use API, Never Double Charge
When you fire off a long-running agent task or workflow, a network hiccup or a retry can cause the same operation to execute twice. Each task step costs $0.05, so a single flaky request can burn your prepaid wallet. The Coasty computer use API solves this with idempotency keys. You attach a unique header to every mutating request, and the server returns 200 OK with the original result on retries, never charging you again.
How it works
The API treats Idempotency-Key as a case-sensitive header. When you submit a run or workflow, include Idempotency-Key: <unique-id>. The server stores the request in a deduplication table keyed by that header. If the same key arrives again, the server returns the stored response without re-executing the agent. This applies to POST /v1/runs and POST /v1/workflows (and any other write endpoints). You can safely retry failed writes using the same key and be sure you are not billed for a second attempt.
#!/bin/bash
export COASTY_API_KEY="$(echo $COASTY_API_KEY)"
RUN_ID="$(uuidgen)"
# POST a task run with an idempotency key
RESULT=$(curl -s -X POST https://coasty.ai/v1/runs \
-H "Authorization: Bearer $COASTY_API_KEY" \
-H "Idempotency-Key: $RUN_ID" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "vm-123",
"task": "Install Python 3.12 and create a virtualenv",
"cua_version": "v4",
"max_steps": 200,
"deadline_seconds": 900
}')
echo "$RESULT"
# Retry the same run with the same key , server returns cached result
RETRY_RESULT=$(curl -s -X POST https://coasty.ai/v1/runs \
-H "Authorization: Bearer $COASTY_API_KEY" \
-H "Idempotency-Key: $RUN_ID" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "vm-123",
"task": "Install Python 3.12 and create a virtualenv",
"cua_version": "v4",
"max_steps": 200,
"deadline_seconds": 900
}')
echo "Retry result: $RETRY_RESULT"
# Both calls bill $0.05 per agent step only on the first run.When idempotency helps
- ●POST /v1/runs retries after network failures without extra cost.
- ●POST /v1/workflows and POST /v1/workflows/{id}/runs can be retried safely.
- ●Idempotency-Key is independent of runs or workflows, you can reuse it across different operations.
- ●The server dedupes on a per-key basis, so a new key is required for a different operation.
Attach Idempotency-Key to every mutating request and guarantee each run costs exactly once.
Where this beats brittle automation
Traditional automation often relies on brittle selectors that break when UI changes. The Coasty computer use agent can see the screen, read text, and act like a human, handling dynamic layouts and cross-page flows. Coupling that with idempotency means you can safely retry long-running, stateful workflows without fear of duplicate charges.
Start building robust computer use agents today. Get your API key at https://coasty.ai/developers and ensure every run is billed exactly once with idempotency keys.