Human in the Loop Automation: awaiting_human and resume in the Runs API
Most automation fails when the UI changes or the agent cannot make a decision. The Coasty computer use API solves this by letting you pause a task run at a human approval step, wait for your input, then resume the run. Use the awaiting_human and resume endpoints to build automation that is accurate, stateful, and user-driven.
How it works
When you POST a task to /v1/runs, the server drives a computer use agent to completion. If the agent needs a human decision, the run enters the awaiting_human state. You then call POST /v1/runs/{id}/resume with a human response to continue. The run can be paused and resumed multiple times. The agent remembers context across pauses because sessions store state. Each agent step costs $0.05.
#!/bin/bash
export COASTY_API_KEY=$(cat ~/.coasty_key)
# Create a run that can be paused for human approval
RUN_ID=$(curl -s -X POST https://coasty.ai/v1/runs \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "aws-ec2-prod-01",
"task": "Log in to https://example.com with username [email protected] and password secret123",
"cua_version": "v3",
"on_awaiting_human": "pause"
}' | jq -r '.id')
echo "Run created: $RUN_ID"
# Wait for the run to reach awaiting_human state
while true; do
STATUS=$(curl -s -X GET "https://coasty.ai/v1/runs/$RUN_ID" \
-H "X-API-Key: $COASTY_API_KEY" | jq -r '.status')
echo "Status: $STATUS"
if [ "$STATUS" = "awaiting_human" ]; then
echo "Run paused. Provide human approval (yes/no)"
read -r APPROVAL
# Resume the run with human approval
curl -s -X POST "https://coasty.ai/v1/runs/$RUN_ID/resume" \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"human_response\": \"approved\"}"
break
fi
sleep 2
done
echo "Run finished. Check status: https://coasty.ai/v1/runs/$RUN_ID"Calling awaiting_human and resume
- ●on_awaiting_human: set to 'pause', 'fail', or 'cancel'. When 'pause', the run enters the awaiting_human state.
- ●awaiting_human state: the run halts. You must call POST /v1/runs/{id}/resume to continue.
- ●POST /v1/runs/{id}/resume accepts a JSON body with human_response. For example, { "human_response": "approved" } or { "human_response": "rejected" }.
- ●Resume can be called multiple times. The agent continues from the last step.
- ●Each agent step is billed $0.05. Paused runs still count steps toward the credit balance.
When on_awaiting_human is 'pause', POST /v1/runs/{id}/resume with human_response is the key to continuing the run.
Where this beats brittle automation
Traditional automation relies on brittle selectors like CSS class names or XPath expressions that break when UIs update. The Coasty computer use API lets the agent see the screen and act like a human, but with the safety net of human approval. You can pause at any decision point, verify the context, and approve or reject actions. This reduces false positives and makes automation resilient to UI changes. Unlike API-only tools, computer use agents can interact with any application, browser, or terminal that a human can use.
Stop building brittle selectors. Use awaiting_human and resume to build automation that pauses for human input and continues with confidence. Get your API key at https://coasty.ai/developers and start building human-in-the-loop automation with the Coasty computer use API.