Automating Form Filling and Checkout Flows Over the Computer Use API
Checkout forms are the hardest part of web automation. They have dynamic IDs, hidden fields, CAPTCHAs, and changing layouts. Traditional tools break when a class name changes. The Coasty Computer Use API solves this by driving a real desktop and browser like a human. You send an instruction and a screenshot, the agent clicks, types, and scrolls until it reaches success. This guide shows how to build an automated checkout flow over the API.
How the Computer Use API handles checkout flows
You start by provisioning a cloud machine with POST /v1/machines. The agent connects to that machine and opens a browser. Then you POST /v1/runs with your task, a machine_id, and a cua_version. The server launches an agent to drive the desktop. The agent captures screenshots, sends them to POST /v1/predict, receives actions, and executes them. It loops until the status is "done". Each agent step costs $0.05. You can stream events from GET /v1/runs/{id}/events to see progress in real time.
# Install dependencies
pip install requests
# Set your API key (never hardcode)
export COASTY_API_KEY="your_key_here"
# Provision a machine
MACHINE_RESPONSE=$(curl -s -X POST https://coasty.ai/v1/machines \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "checkout-demo"}'
)
MACHINE_ID=$(echo $MACHINE_RESPONSE | jq -r '.machine_id')
# Start the agent
RUN_RESPONSE=$(curl -s -X POST https://coasty.ai/v1/runs \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"machine_id": "$MACHINE_ID",
"task": "Go to https://demo.coasty.ai/checkout, fill the email field with [email protected], fill the card number with 4242424242424242, fill the expiry with 12/30, fill the CVC with 123, click the submit button, and confirm the order is placed.",
"cua_version": "v4",
"instructions": "Be careful to click the correct submit button and avoid accidental navigation.",
"max_steps": 50,
"deadline_seconds": 300
}'
)
RUN_ID=$(echo $RUN_RESPONSE | jq -r '.run_id')
echo "Run started: $RUN_ID"
# Stream events until done
curl -s -N -H "X-API-Key: $COASTY_API_KEY" \
"https://coasty.ai/v1/runs/$RUN_ID/events" | while IFS= read -r line; do
if [[ $line == data:* ]]; then
EVENT=$(echo $line | sed 's/data: //')
echo $EVENT | jq .
STATE=$(echo $EVENT | jq -r '.state')
if [[ $STATE == "succeeded" || $STATE == "failed" ]]; then
break
fi
fi
doneKey fields for checkout automation
- ●machine_id: the cloud VM the agent drives (POST /v1/machines).
- ●task: natural language that tells the agent what to do (e.g. fill email, click submit).
- ●cua_version: use "v4" for autonomous mode with pass/fail verification.
- ●instructions: additional constraints appended to the base prompt.
- ●max_steps: how many agent steps to run (default depends on deadline).
- ●deadline_seconds: how long the agent has to finish (default 300).
- ●on_awaiting_human: set to "pause", "fail", or "cancel" when the agent needs approval.
- ●Each agent step is billed $0.05.
POST /v1/runs is your entry point to drive a real desktop and browser for checkout flows.
Where this beats brittle automation
Traditional tools rely on CSS selectors, XPath, or element IDs. When a site changes a class name or reorders fields, your script breaks. The Coasty Computer Use API sees the screen and acts like a human. It can handle CAPTCHAs if you provide a helper, it can scroll to reveal buttons, and it can adapt to changing layouts without code changes. You describe the goal in plain language, not selectors, and the agent finds the right elements for you.
With the Coasty Computer Use API you can build reliable automated checkout flows and form filling bots that work across any website. Start by provisioning a machine, then POST /v1/runs with a clear task and a deadline. Stream events to see progress and handle human approval when needed. Get your API key at https://coasty.ai/developers and start automating your checkout flows today.