Every web app has a checkout flow. Captcha, dynamic IDs, changing layouts, and confusing prompts break traditional selectors. A computer use agent can see the screen, understand context, and act like a human. In this post we wire the Coasty Computer Use API to fill a form and complete a checkout, using only real endpoints and pricing.
How it works
We use a task run to drive a real browser. We send a machine_id, a task describing the flow, and the CUA version. The server provisions a cloud VM, launches a browser, and sends instructions to the agent. It captures screenshots, predicts the next action, and returns result objects until the task finishes. We poll the run status and stream events to watch progress.
import os
import json
import requests
COASTY_API_KEY = os.getenv("COASTY_API_KEY")
BASE_URL = "https://coasty.ai/v1"
HEADERS = {
"Authorization": f"Bearer {COASTY_API_KEY}",
}
# Provision a cloud VM to drive the browser
machines_resp = requests.post(
f"{BASE_URL}/machines",
headers=HEADERS,
json={"name": "checkout-bot-test"},
)
machines_resp.raise_for_status()
machine = machines_resp.json()
machine_id = machine["id"]
print("Provisioned machine:", machine_id)
# Define the checkout flow as a task
checkout_task = (
"Navigate to https://example.com/products and select a product."
"Add it to the cart."
"Open the cart, fill in the shipping form with the data from the user."
"Fill in the payment details using the test card information."
"Complete the order by clicking the checkout button."
)
# Start a task run on that machine
runs_resp = requests.post(
f"{BASE_URL}/runs",
headers=HEADERS,
json={
"machine_id": machine_id,
"task": checkout_task,
"cua_version": "v4",
"max_steps": 200,
"deadline_seconds": 600,
"on_awaiting_human": "pause",
},
)
runs_resp.raise_for_status()
run = runs_resp.json()
run_id = run["id"]
print("Run started:", run_id)
# Poll for status until done
import time
while True:
status_resp = requests.get(
f"{BASE_URL}/runs/{run_id}",
headers=HEADERS,
)
status_resp.raise_for_status()
status = status_resp.json()
print("Status:", status)
if status["status"] in ("succeeded", "failed", "cancelled", "timed_out"):
break
time.sleep(3)
# Stream events to see actions as they happen
events_resp = requests.get(
f"{BASE_URL}/runs/{run_id}/events",
headers=HEADERS,
)
events_resp.raise_for_status()
for line in events_resp.iter_lines():
if line:
print("Event:", line.decode())
print("Final status:", status["status"])Run states and billing
- Run states include queued, running, awaiting_human, succeeded, failed, cancelled, and timed_out.
- Billing is $0.05 per agent step for task runs.
- You can pause work when the task encounters a human approval with on_awaiting_human: pause.
- You can cancel or resume a run using POST /v1/runs/{id}/cancel and POST /v1/runs/{id}/resume.
The run endpoint and task description drive a cloud VM with a browser, so your agent sees the same layout a real user sees.
Where this beats brittle automation
Traditional tools rely on CSS selectors or XPath that break on class name changes or layout shifts. The computer use agent reads the screenshot and understands context, so it can type the right text even if the field id changes, or click the correct button when a new design is released. It can also handle unexpected dialogs, alerts, and pop‑ups natively, reducing false positives and maintenance.
Extending the flow
- Use the workflow DSL to sequence multiple checkout flows, retries, and assertions.
- Parse generated pyautogui code with the free /v1/parse endpoint to inspect steps before running.
- Ground UI elements to coordinates with /v1/ground for precision clicks and fills.
- Add assertions to verify price totals, confirmation messages, or successful redirects.
You now have a working pattern for form filling and checkout automation over the API. Get a key and start building robust computer use agents at https://coasty.ai/developers.
Want to see this in action?
View Case Studies