Orchestrate Multi-Step Automations with the Workflows API
Most desktop automation scripts are fragile one-offs. You hardcode UI selectors, wait for static timeouts, and fail when layouts shift. The Workflows API gives you a versioned JSON DSL to define multi-step, conditional, and looped workflows that run on real cloud VMs. The server drives the agent, streams events, and manages state so you can orchestrate complex tasks reliably.
How it works
A workflow is a JSON object you POST to /v1/workflows. Each step is one of task, assert, if, loop, parallel, human_approval, retry, succeed, or fail. You can pass variables using double-brace syntax like {{inputs.username}} or stepId.field. The server provisions a machine_id, runs the workflow, and streams events via SSE. You can also start a workflow run inline or as a versioned workflow. Task steps are billed $0.05 per agent step.
curl -X POST https://coasty.ai/v1/workflows \
-H "X-API-Key: $COASTY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "login-and-search",
"steps": [
{
"type": "task",
"task": "Log into the app as {{inputs.username}} using password {{inputs.password}}."
},
{
"type": "assert",
"condition": {
"field": "login.result",
"operator": "is",
"value": "success"
}
},
{
"type": "task",
"task": "Search for product {{inputs.product}} and open the first result."
},
{
"type": "loop",
"condition": {
"field": "loop.counter",
"operator": "lt",
"value": 3
},
"steps": [
{
"type": "task",
"task": "Add the product to the cart."
},
{
"type": "human_approval",
"instruction": "Review cart and confirm checkout."
},
{
"type": "task",
"task": "Complete checkout."
}
]
},
{
"type": "succeed"
}
],
"variables": {
"loop.counter": 0
}
}' | jq .Step types and hard guards
- ●task: runs a computer use agent with the given instruction. Billed $0.05 per agent step.
- ●assert: validates a field from a previous step against an operator (is, eq, ne, lt, gt).
- ●if: branches based on a condition object.
- ●loop: repeats a list of steps while a condition holds. You can increment loop.counter manually or via a retry step.
- ●parallel: runs multiple steps concurrently (subject to server capacity).
- ●human_approval: pauses for manual interaction and returns a pass/fail result.
- ●retry: retries a task step up to max_iterations times before failing.
POST /v1/workflows with a JSON DSL, then GET /v1/workflows/{id}/runs to track progress.
Where this beats brittle automation
Selectors break when a page changes. APIs change versions. UI components move on the screen. The Workflows API runs on real desktops and browsers driven by a computer use agent. The agent sees the screen, interprets text, and clicks buttons naturally. You describe intent, not DOM structure. The server retries failed assertions, loops until conditions clear, and streams events so you know exactly when a step completes. You get observability and resilience built in.
Tracking workflow runs
After you POST /v1/workflows, you receive a workflow ID. To start a run, POST /v1/workflows/{id}/runs with optional machine_id, deadline_seconds, and inputs. GET /v1/workflows/{id}/runs returns run IDs. Use GET /v1/runs/{id} for status and GET /v1/runs/{id}/events to stream progress via Server-Sent Events. Reconnect with the Last-Event-ID header. States include queued, running, awaiting_human, succeeded, failed, cancelled, and timed_out.
Ready to build multi-step, resilient automations? Get a key at https://coasty.ai/developers and start scripting workflows with the Workflows API.