Back to Blog
Tutorial

Emily Watson8 min
+B

Most desktop automation tools either require you to hardcode selectors or rely on fragile UI APIs that break when apps update. You need a way to describe what to accomplish in plain language and have the system figure out the clicks, keystrokes, and navigation. The Coasty computer use API gives you that capability using task runs. You submit a task, get a run ID, and receive real-time events as an agent drives a cloud machine to completion. This approach works for any app with a visible UI, from desktop utilities to web apps and terminal sessions. Billing is predictable at $0.05 per agent step. The API handles retries, deadlines, and human interaction states so you can focus on building business logic.

How it works

A task run follows these steps. First, POST /v1/runs with a JSON payload that includes machine_id (a cloud VM you provision), task (the natural language goal you want to achieve), and optional instructions that get appended to the base prompt. You can set cua_version to 'v3' for standard behavior or 'v4' to enable an autonomous mode with a pass/fail verifier. You control the run with max_steps, deadline_seconds, on_awaiting_human (choose 'pause', 'fail', or 'cancel'), and a webhook_url for event delivery. The server returns a run_id. You then retrieve events with GET /v1/runs/{id}/events which streams Server-Sent Events. A status field indicates the current state: queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out. When the status is 'done', the agent has completed the task. You can pause, resume, or cancel the run at any time using the corresponding endpoints.

bash
curl https://coasty.ai/v1/runs \ 
-H "X-API-Key: $COASTY_API_KEY" \ 
-H "Content-Type: application/json" \ 
-d '{\n  "machine_id": "vm-12345",\n  "task": "Click the Install button, wait five seconds, then close the installer window",\n  "cua_version": "v3",\n  "max_steps": 20,\n  "deadline_seconds": 120,\n  "on_awaiting_human": "pause",\n  "webhook_url": "https://your-server.coasty-hook"\n}'

Run states and lifecycle

  • queued: the task is waiting for a machine to become available
  • running: the agent is actively driving the desktop
  • awaiting_human: the agent paused and is waiting for you to resolve an ambiguous situation
  • succeeded: the agent completed the task and the final event confirms success
  • failed: the agent could not finish, check events for details
  • cancelled: you canceled the run with POST /v1/runs/{id}/cancel
  • timed_out: the deadline_seconds threshold was exceeded

The run_id you get from POST /v1/runs is the key to monitoring progress. Use GET /v1/runs/{id}/events to stream real-time status updates.

Where this beats brittle automation

Traditional automation tools require you to know exactly which UI element to interact with. If an app changes its button class or layout, your scripts break. With a computer use agent, you only describe the goal in natural language. The agent sees the screen and performs clicks and keystrokes exactly as a human would. This approach works even when the app uses dynamic selectors, custom controls, or complex workflows that span multiple windows. You can automate tasks that span browsers, desktop applications, and terminal sessions on the same machine. The agent handles the navigation, so your code stays simple and resilient to UI changes.

You can now build robust automation that adapts to UI changes. Start by setting up a prepaid wallet in the Coasty dashboard, then create a machine and submit your first task run. Explore workflows for multi-step processes and experiment with the v4 agent for autonomous mode. To get your API key, visit https://coasty.ai/developers. Build smarter automation with the Coasty computer use API.

© 2026 Coasty

Backed byYCombinator