Most automation code is a long chain of brittle selectors and API calls. When a UI changes, you rewrite the whole script. The Coasty workflow DSL lets you define structured sequences of task, assert, if, loop, and parallel steps, then submit them as a versioned JSON document to /v1/workflows. The server drives an AI agent on a real machine, executes your workflow, and streams events back to you. You get stateful orchestration with a single POST call.
How the workflow DSL works
Send a JSON document to POST /v1/workflows. The body is a versioned workflow definition with steps of the following types: task, assert, if, loop, parallel, human_approval, retry, succeed, and fail. Each task step is billed $0.05 per agent step. Variables are written as double braces, for example {{inputs.username}} or stepId.field. Hard guards include budget_cents, max_iterations, and deadline_seconds. The server returns a workflow id you can use to create runs via POST /v1/workflows/{id}/runs or ad-hoc inline with POST /v1/workflows/runs. Each run tracks its own state: queued, running, awaiting_human, succeeded, failed, cancelled, or timed_out.
curl https://coasty.ai/v1/workflows \ \
-H "X-API-Key: $COASTY_API_KEY" \ \
-H "Content-Type: application/json" \ \
-d '{
"version": "1.0",
"steps": [
{
"type": "task",
"name": "login_step",
"instruction": "Open the login page and type the username {{inputs.username}} and the password {{inputs.password}}. Then click the submit button."
},
{
"type": "assert",
"name": "assert_login_success",
"condition": {
"type": "element_exists",
"selector": "text contains "Welcome back""
}
},
{
"type": "if",
"name": "check_two_factor",
"condition": {
"type": "element_exists",
"selector": "text contains "Two-Factor Code""
},
"steps": [
{
"type": "task",
"name": "enter_2fa",
"instruction": "Enter the two-factor code from the user input."
}
]
},
{
"type": "loop",
"name": "checkout_loop",
"condition": {
"type": "element_exists",
"selector": "text contains "Add to cart""
},
"max_iterations": 5,
"steps": [
{
"type": "task",
"name": "add_item",
"instruction": "Click the Add to Cart button."
},
{
"type": "assert",
"name": "item_added",
"condition": {
"type": "element_exists",
"selector": "text contains "Item added""
}
}
]
},
{
"type": "parallel",
"name": "parallel_upload",
"steps": [
{
"type": "task",
"name": "upload_image",
"instruction": "Upload the file {{inputs.image_path}}."
},
{
"type": "task",
"name": "save_settings",
"instruction": "Save the account settings."
}
]
},
{
"type": "succeed"
}
]
}'Step types in detail
- task: instructs the agent to perform an action on the screen with a natural language instruction. Each task step is billed $0.05.
- assert: checks a condition on the current state, such as element_exists or text contains. If the condition fails, the workflow fails.
- if: executes a block of steps only when the condition evaluates to true. You can nest if blocks for complex logic.
- loop: repeatedly runs a block of steps while a condition holds, up to max_iterations. Useful for pagination or retry scenarios.
- parallel: runs multiple task steps concurrently. Each parallel branch executes independently on the same machine.
- human_approval: pauses the run for human intervention. Set the on_awaiting_human option to "pause", "fail", or "cancel" in the run request.
- retry: repeats a task step if it fails, up to a configured retry count.
- succeed: marks the run as successful and ends the workflow.
- fail: marks the run as failed and ends the workflow.
Each task step is billed $0.05 per agent step.
Where this beats brittle automation
With selectors and API-only tools, you must maintain DOM paths and endpoint contracts. A single UI change breaks your script. The workflow DSL abstracts the UI into natural language instructions and structured conditions. The AI agent observes the screen, interprets your intent, and adapts to layout changes. You get declarative orchestration where the agent handles the details. This is the power of a computer use agent: see the screen and act like a human, not a fragile script.
Start building structured agents with the workflow DSL. Create a workflow with task, assert, if, loop, and parallel steps, then POST /v1/workflows/runs. Monitor runs with GET /v1/runs and stream events with GET /v1/runs/{id}/events. Get your API key and start automating at https://coasty.ai/developers.
Want to see this in action?
View Case Studies