Tutorial

How to Build an Autonomous Agent with the /v1/runs Computer Use API

Alex Thompson||7 min
+Z

Most automation tools rely on brittle selectors or fixed APIs that break when UI changes. You want an agent that can use a real desktop and navigate apps like a human. The Coasty /v1/runs endpoint is designed for exactly this. It provisions a cloud VM and launches an agent that executes steps until success, failure, or cancellation. You control the entire lifecycle with a single API call and get real-time visibility through events and webhooks.

How /v1/runs works

The runs API is the easiest way to spin up an autonomous task. You POST to /v1/runs with a machine configuration, the task description, optional instructions, and a few controls. The server provisions a cloud VM, starts an agent, and drives it through steps. Each step costs $0.05. You can inspect the run via GET /v1/runs/{id}, stream events via GET /v1/runs/{id}/events, and cancel or resume with POST /v1/runs/{id}/cancel and POST /v1/runs/{id}/resume. The agent supports both scripted and autonomous modes via the cua_version parameter.

bash
curl -X POST https://coasty.ai/v1/runs \
  -H "X-API-Key: $COASTY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machine_id": "m-12345",
    "task": "Open Chrome, go to https://example.com, and click the first link.",
    "cua_version": "v4",
    "max_steps": 20,
    "deadline_seconds": 300,
    "on_awaiting_human": "pause",
    "webhook_url": "https://your-domain.com/hooks/coasty"
  }'

Key fields and behaviors

  • machine_id: the cloud VM to use (provisioned via /v1/machines).
  • task: natural language description of what the agent should do.
  • cua_version: use "v3" for scripted mode or "v4" for autonomous mode with pass/fail verification.
  • instructions: optional, appended directly to the agent prompt.
  • max_steps: maximum agent steps before the run fails automatically.
  • deadline_seconds: total time limit for the run.
  • on_awaiting_human: pause, fail, or cancel when the agent waits for human input.
  • webhook_url: receives a signed POST when the run reaches succeeded, failed, cancelled, or timed_out.
  • All writes are idempotent when you pass an Idempotency-Key header.

POST /v1/runs creates an autonomous agent that drives a real desktop for $0.05 per step.

Where this beats brittle automation

Coasty nodes drive actual desktops and browsers, not just selectors or API calls. If a page layout changes, the agent still sees the screen and navigates using visual cues. This means you can automate tasks that have no stable API, such as clicking a dynamic button, filling a form, or inspecting a live dashboard. You also get full visibility into every agent step and state change through events and webhooks, so you can debug failures without replaying logs.

Next steps

Start with a simple task using POST /v1/runs and monitor events. Once you are comfortable, explore workflows to chain multiple tasks, add conditional logic, and define retry strategies. You can also use the MCP server to drive Coasty directly from Cursor, Claude Desktop, or other MCP clients. Ready to build an autonomous agent that handles real tasks? Get your key at https://coasty.ai/developers.

Want to see this in action?

View Case Studies
Try Coasty Free