Tutorial

Automating Form Filling and Checkout Flows Over the API

Rachel Kim||7 min
F12

Checkout flows are notoriously hard to automate. Forms change layout, buttons reposition, and validation messages appear in unexpected spots. Traditional automation tools rely on brittle selectors or require you to reverse-engineer every page. The Coasty computer use API lets you describe what you want to do in plain language and drives a real browser or desktop to complete the task. You send a screenshot and an instruction, and the agent returns the next actions to take. This turns a fragile, selector-heavy script into a robust, intent-based workflow.

How it works

You start by provisioning a machine to host the automation environment. POST /v1/machines creates a cloud VM and returns a machine_id. Then you use the stateful predict endpoint to drive the agent. POST /v1/sessions creates a session, and POST /v1/sessions/{id}/predict takes a screenshot and instruction and returns actions plus a status. The agent loops capture, predict, act until status is "done". Each predict call is billed at $0.04. For a quick checkout flow you can also use the stateless endpoint POST /v1/predict ($0.05) which returns actions in a single call.

bash
# Provision a machine and start a checkout automation
export COASTY_API_KEY="your-key"

# Create a machine and capture the ID
MACHINE_ID=$(curl -s -X POST https://coasty.ai/v1/machines \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "checkout-bot"}' | jq -r '.machine_id')

# Capture a screenshot of the checkout page
SCREENSHOT=$(curl -s -X POST https://coasty.ai/v1/sessions \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"machine_id": "$MACHINE_ID", "cua_version": "v3"}' | jq -r '.session_id')

# Encode and send the screenshot with an instruction
curl -s -X POST https://coasty.ai/v1/sessions/$SCREENSHOT/predict \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "screenshot": "$(base64 -w0 screenshot.png)",
    "instruction": "Fill in the shipping address with Jane Doe, 123 Main St, Apt 4, San Francisco, CA 94102, zip 94102, and click Place Order.",
    "cua_version": "v3"
  }' | jq .

Key fields and billing

  • machine_id: returned from POST /v1/machines and used for all subsequent calls.
  • session_id: returned from POST /v1/sessions and used as the path in POST /v1/sessions/{id}/predict.
  • screenshot: base64-encoded image sent in each predict request.
  • instruction: natural language description of the action to take.
  • cua_version: set to "v3" for guided mode or "v4" for autonomous mode with a pass/fail verifier.
  • status: returned in the predict response; loop until status is "done".
  • Each predict call (stateless or stateful) is billed at $0.04 or $0.05 respectively.

POST /v1/sessions/{id}/predict is the core endpoint for stateful trajectory memory, each predict costs $0.04.

Where this beats brittle automation

Traditional automation tools break when a form field moves by a few pixels or when a validation message appears in a new location. They also require you to maintain separate scripts for each page or each checkout flow variant. The computer use API lets you describe the goal in plain language: "fill in the shipping address with Jane Doe, 123 Main St, Apt 4, San Francisco, CA 94102, zip 94102, and click Place Order." The agent sees the current layout and clicks the correct fields and buttons each time. You don’t need selectors, XPath, or CSS classes. You also don’t need to rebuild your script when the layout changes.

Next steps

  • Provision a machine and start a session with POST /v1/sessions.
  • Use POST /v1/sessions/{id}/predict to drive the agent through a multi-step checkout flow.
  • Upgrade to cua_version "v4" for autonomous mode with built-in pass/fail verification.
  • Combine checkout automation with workflows to orchestrate multi-page flows, retries, and approvals.
  • Get an API key at https://coasty.ai/developers and start building robust checkout bots.

The Coasty computer use API gives you a reliable way to automate form filling and checkout flows without maintaining brittle selectors. You drive a real browser or desktop by describing what you want to do. Each predict call is billed at $0.04, so you only pay for successful steps. Build resilient checkout bots, test flows programmatically, and scale automation across environments with a single API. Get your key at https://coasty.ai/developers and start automating today.

Want to see this in action?

View Case Studies
Try Coasty Free