Back to Blog
Guide

Emily Watson6 min
F12

A typical RPA script is a long chain of conditional branches and loops that must be rewritten when a UI changes. The Workflows API on the Coasty computer use API lets you define a versioned JSON workflow that the server executes step by step. Each step can run a task, assert a state, retry, or parallelize, and the environment persists across steps because the server drives the same machine for the whole run. This approach gives you durable, observable multi-step automations without brittle selectors or fragile manual scripting.

How the workflows DSL works

A workflow is a versioned JSON document you POST to /v1/workflows. The payload includes the DSL version, a list of steps, any input variables, and optional guard rails such as budget_cents, max_iterations, and deadline_seconds. Step types include task, assert, if, loop, parallel, human_approval, retry, succeed, and fail. Each task step runs a computer use agent on the machine you provision and costs $0.05 per step. The server executes the steps sequentially or in parallel, updating a shared state that other steps can read or write using expressions like {{inputs.x}} or stepId.field. After the final step resolves to succeed or fail, the run ends and you can retrieve results from the run endpoint and events stream.

python
import os
import json
import httpx

API_BASE = "https://coasty.ai/v1"
API_KEY = os.environ.get("COASTY_API_KEY")

def create_workflow():
    workflow = {
        "version": "1",
        "variables": [{"name": "url", "type": "string"}],
        "steps": [
            {
                "id": "step1",
                "type": "task",
                "cua_version": "v3",
                "task": "Open the web browser and navigate to {{inputs.url}}",
                "instructions": "Use the web browser to load the provided URL",
                "on_awaiting_human": "pause"
            },
            {
                "id": "step2",
                "type": "assert",
                "assertions": [
                    {
                        "type": "text",
                        "selector": "body",
                        "content": "Welcome",
                        "required": True
                    }
                ]
            },
            {
                "id": "step3",
                "type": "task",
                "cua_version": "v3",
                "task": "Click the Sign in button and enter a username and password",
                "instructions": "Sign in using the provided credentials",
                "on_awaiting_human": "pause"
            },
            {
                "id": "step4",
                "type": "succeed"
            }
        ],
        "budget_cents": 200,
        "max_iterations": 10,
        "deadline_seconds": 600
    }
    response = httpx.post(
        f"{API_BASE}/workflows",
        headers={"X-API-Key": API_KEY, "Content-Type": "application/json"},
        json=workflow
    )
    response.raise_for_status()
    return response.json()

if __name__ == "__main__":
    workflow = create_workflow()
    print(json.dumps(workflow, indent=2))

Running a workflow

  • POST /v1/workflows/{id}/runs starts a workflow execution. The payload can include override inputs or reuse the original variables.
  • Each task step costs $0.05. The server bills you per agent step, not per workflow definition.
  • GET /v1/runs/{id} returns the final state (queued, running, awaiting_human, succeeded, failed, cancelled, timed_out) and any output fields your steps expose.
  • GET /v1/runs/{id}/events streams Server-Sent Events for real-time telemetry. Reconnect with the Last-Event-ID header to continue after a network interruption.

Every task step is billed $0.05, and the server persists state across steps on the same machine.

Where this beats brittle automation

Traditional UI automation relies on hard-coded selectors and fragile XPath or CSS patterns that break every time a product UI changes. The computer use agent on the Coasty platform sees the screen like a human, identifies buttons and inputs by visual context, and clicks or types accordingly. By combining this visual intelligence with a workflows definition, you can create end-to-end flows, login, data entry, navigation, file operations, that survive minor UI style changes. The workflow also gives you structured control flow, retry logic, and human approval gates that are hard to maintain in a monolithic script.

Try building a multi-step automation that logs into a web app, fills a form, and retrieves a confirmation page. Define the flow as a versioned workflow on the computer use API, provision a machine, and start a run. Get your API key at https://coasty.ai/developers and start orchestrating reliable, observable automation at scale.

© 2026 Coasty

Backed byYCombinator