Back to Blog
Engineering

David Park6 min
Ctrl+P

Traditional automation scripts fail when they hit a UI element that changes location, a CAPTCHA, or a legal approval screen. The Coasty Runs API can pause an agent run when it encounters an awaiting_human state, return the last event payload, and resume later. This lets you approve payments, verify two-factor authentication, or manually fix a navigation glitch without rewriting your code.

How awaiting_human and resume work

When you start a task run with POST /v1/runs, the agent moves through states like queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out. The state changes are exposed through GET /v1/runs/{id}/events, which streams Server-Sent Events. When the agent reaches awaiting_human, you can inspect the latest event payload, request the user to approve, then POST /v1/runs/{id}/resume to continue the run. The runs endpoint charges $0.05 per agent step regardless of the state.

bash
# Start a run that may require human approval
API_KEY="$(cat COASTY_API_KEY)"
RUN_ID=$(curl -s -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "aws-us-east-1-prod-001",
    "task": "open chatgpt and ask for a summary of the latest AI news",
    "cua_version": "v4",
    "max_steps": 100,
    "deadline_seconds": 600,
    "on_awaiting_human": "pause"
  }' | jq -r .id)

echo "Run created: $RUN_ID"

# Poll for state changes via events
curl -s -N "https://coasty.ai/v1/runs/$RUN_ID/events" \
  -H "X-API-Key: $API_KEY" \
  --no-buffer | while IFS= read -r line; do
    if [[ "$line" =~ awaiting_human ]]; then
      echo "Agent paused: awaiting human approval"
      # In real code, inspect the event payload for detail
      break
    fi
  done

# Resume after human approval
curl -s -X POST "https://coasty.ai/v1/runs/$RUN_ID/resume" \
  -H "X-API-Key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

echo "Run resumed: $RUN_ID"

Key parameters and billing

  • POST /v1/runs fields: machine_id (required), task (required), cua_version (default v3, v4 adds a pass/fail verifier), max_steps, deadline_seconds, on_awaiting_human (pause, fail, or cancel), system_prompt, instructions (appended to the base prompt), webhook_url.
  • State transitions: queued -> running -> awaiting_human -> succeeded/failed/cancelled/timed_out.
  • Billing: $0.05 per agent step regardless of state.
  • Events endpoint GET /v1/runs/{id}/events streams Server-Sent Events with Last-Event-ID for reconnection.

When the agent hits awaiting_human, pause the run and resume after human approval.

Why computer use beats brittle automation

A pure API automation might assume a specific element ID or XPath that breaks when UI changes. A computer use agent can read the screen, see a CAPTCHA, detect a bank approval modal, or follow a new navigation path. The awaiting_human and resume flow lets you intervene when the agent cannot proceed but still reuse its stateful trajectory memory and history of actions.

Add human approval steps to your workflows with awaiting_human and resume. Build approval gates for payments, 2FA flows, or content moderation without hard-coding every edge case. Get a key at https://coasty.ai/developers and start building human-in-the-loop computer use agents.

© 2026 Coasty

Backed byYCombinator