Tutorial

How to Automate Any Desktop App with the Coasty Computer Use API

Priya Patel||8 min
+B

Automating a desktop app usually means writing brittle selectors, parsing HTML, and maintaining code as the UI changes. The Coasty computer use API turns that around. You send a task and an instruction, and an agent sees the screen, understands it, and clicks or types just like a human. You pay only for the agent steps it takes, not per API call. In this guide you will build a script that drives a real browser to log in and upload a file, using the exact endpoints and prices described in the Coasty documentation.

How it works

The Coasty computer use API runs a computer use agent on a cloud VM. The agent loops capture, predict, act until the task is done. The core request flow uses /v1/runs. You POST a task with a machine_id, a cua_version (v3 or v4), and a deadline_seconds. The server starts an agent, streams events, and bills $0.05 per step. When the agent succeeds, you stop. The /v1/runs/{id}/events endpoint streams Server-Sent Events with states such as queued, running, succeeded, failed, cancelled, or timed_out. You can pause, resume, or cancel runs via /v1/runs/{id}/cancel and /v1/runs/{id}/resume.

bash
#!/bin/bash
# Submit a simple browser automation task via curl

export COASTY_API_KEY=$(cat ~/.coasty_key)
machine_id="vm-abc123"
cua_version="v3"
max_steps=100
deadline_seconds=300
task="Log in to https://example.com with username [email protected] and password TestPass123, then upload /tmp/test.txt"

response=$(curl -s -X POST https://coasty.ai/v1/runs \
  -H "Authorization: Bearer $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"machine_id\": \"$machine_id\",
    \"task\": \"$task\",
    \"cua_version\": \"$cua_version\",
    \"max_steps\": $max_steps,
    \"deadline_seconds\": $deadline_seconds
  }")

run_id=$(echo "$response" | jq -r .id)
echo "Submitted run $run_id"

Track progress and stream events

  • GET /v1/runs returns a list of your runs with id, state, created_at, updated_at.
  • GET /v1/runs/{id} shows the full run details including task, max_steps, steps_taken, and final status.
  • GET /v1/runs/{id}/events streams Server-Sent Events with state and any structured payload you emit.

Use /v1/runs/{id}/events with Last-Event-ID to resume after network interruptions.

Where this beats brittle automation

Traditional automation tools rely on fixed selectors or APIs that may not exist. If the app changes its classes or layout, your script breaks. With the Coasty computer use API the agent sees the real screen and adapts. It can handle UI changes, dynamic content, and even mixed environments like a browser plus a terminal in the same session. You do not need to maintain a huge selector database. You only need to describe what you want in natural language. The agent turns your instruction into clicks, keystrokes, and waits.

Advanced: workflows and machines

  • POST /v1/workflows creates a versioned JSON DSL of runs. It supports task, assert, if, loop, parallel, human_approval, retry, succeed, and fail steps. You can guard with budget_cents, max_iterations, and deadline_seconds.
  • POST /v1/machines provisions a cloud VM you can start, stop, and snapshot. The agent runs on real desktops, browsers, and terminals.
  • MCP server integration lets you drive Coasty from Cursor, Claude Desktop, or other MCP clients, keeping your automation in the same environment you code in.

You now have a working model for automating any desktop app with the Coasty computer use API. Use /v1/runs to start agents, stream events to track progress, and manage runs with /v1/runs/{id}/cancel and /v1/runs/{id}/resume. Build workflows with /v1/workflows and provision machines with /v1/machines. When you are ready to start, get a key at https://coasty.ai/developers and build your first computer use agent.

Want to see this in action?

View Case Studies
Try Coasty Free