Orchestrating Multi-Step Automations With the Workflows API
Robust automation is hard when you rely on brittle selectors or manually stitching together API calls. The Coasty Workflows API gives you a versioned JSON DSL to orchestrate multi-step computer use automations. You can define tasks, loops, retries, and conditions with clear guards like budget_cents, max_iterations, and deadline_seconds. Each agent step costs $0.05, and the server drives the agent to completion using real desktops, browsers, or terminals.
How the Workflows DSL works
A workflow is a versioned JSON document that describes a sequence of steps. You POST the workflow to /v1/workflows. Each step has a type: task, assert, if, loop, parallel, human_approval, retry, succeed, or fail. Task steps run a computer use agent with a task description, optional instructions, cua_version (default v3, v4 is autonomous with a pass/fail verifier), and system_prompt. Conditions are structured objects, and variables can reference inputs ({{inputs.x}}) or step outputs ({{stepId.field}}). Hard guards like budget_cents, max_iterations, and deadline_seconds apply globally. After provisioning, you run the workflow with /v1/workflows/{id}/runs or POST /v1/workflows/runs for ad-hoc inline workflows. The run returns a machine_id and a task_id. GET /v1/runs streams Server-Sent Events for status changes: queued, running, awaiting_human, succeeded, failed, cancelled, timed_out.
Example workflow DSL for a multi-step automation.
cat > workflow.json << 'EOF'
{
"version": "1.0",
"variables": {
"max_retries": 3,
"deadline_seconds": 300
},
"steps": [
{
"id": "setup",
"type": "task",
"task": "Open Chrome and navigate to https://example.com",
"cua_version": "v3",
"system_prompt": "Act as a web user on Chrome."
},
{
"id": "assert_title",
"type": "assert",
"condition": {
"type": "text_match_on_screen",
"text": "Example Domain"
}
},
{
"id": "click_link",
"type": "task",
"task": "Click the first link that contains 'more'.",
"cua_version": "v3"
},
{
"id": "loop_pages",
"type": "loop",
"condition": {
"type": "exists",
"selector": "a[href*='next']"
},
"body": [
{
"id": "click_next",
"type": "task",
"task": "Click the next page link.",
"cua_version": "v3"
},
{
"id": "verify_content",
"type": "assert",
"condition": {
"type": "text_match_on_screen",
"text": "Example Domain"
}
}
],
"max_iterations": 10,
"deadline_seconds": 120
},
{
"id": "succeed",
"type": "succeed"
}
],
"hard_guards": {
"budget_cents": 100,
"max_iterations": 20,
"deadline_seconds": 300
}
}
EOF
# Deploy the workflow
API_KEY="$(cat COASTY_API_KEY)"
curl -s -X POST https://coasty.ai/v1/workflows \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d @workflow.json | jq .
# Run the workflow
RUN_ID=$(curl -s -X POST https://coasty.ai/v1/workflows/{id}/runs \
-H "X-API-Key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"machine_id": "your_machine_id"}' | jq -r .run_id)
# Stream run events
curl -s -N https://coasty.ai/v1/runs/$RUN_ID/events \
-H "X-API-Key: $API_KEY"Step types and conditions
- ●task runs a computer use agent with a task description, cua_version, and optional system_prompt. Each task step costs $0.05.
- ●assert verifies that a condition is true. Conditions include text_match_on_screen, exists, and custom structured objects.
- ●if branches execution based on a condition, allowing parallel or conditional execution of sub-steps.
- ●loop repeats a body until a condition fails or max_iterations is reached, useful for paginated workflows.
- ●retry wraps other steps to automatically retry on failure, with configurable max_attempts and backoff.
- ●parallel creates concurrent sub-workflows, useful for splitting independent tasks across multiple agents.
- ●human_approval pauses the workflow until you approve with a webhook callback or manual action.
- ●succeed or fail terminates the workflow with success or failure, respectively.
Post your workflow to /v1/workflows, then run it with /v1/workflows/{id}/runs. Each agent step is billed at $0.05.
Why this beats brittle automation
Traditional automation relies on brittle selectors, hardcoded URLs, and fragile APIs. The Workflows API lets you describe intent in natural language and let the agent use vision to see and act on the screen. Tasks like 'Open Chrome and navigate to https://example.com' or 'Click the first link that contains more' are handled by the agent, not by you maintaining selectors. You can add loops, retries, and conditions with the DSL, and hard guards like budget_cents and deadline_seconds prevent runaway costs. The server drives the agent on real desktops and browsers, so your automation works even when UI changes.
Start orchestrating multi-step automations with the Coasty Workflows API. Define your workflow as a versioned JSON document, deploy it to /v1/workflows, and run it with /v1/workflows/{id}/runs. Get your API key at https://coasty.ai/developers to start building.