The Workflow DSL Explained: Task, Assert, If, Loop, Parallel
You want to drive a real browser or desktop to completion, but each step depends on the last. A simple script fails when elements shift or the app changes. The Coasty workflow DSL lets you model that logic declaratively, then hand it off to an agent that sees the screen and acts like a human. Define tasks, asserts, branching, loops, and parallel work in a versioned JSON DSL, then POST to /v1/workflows to start an orchestrated run.
How the workflow DSL works
You POST a JSON workflow object to /v1/workflows. The DSL is versioned; each workflow includes a 'version' field that the server uses to load the correct parser. The body contains a 'steps' array where each step can be one of the documented types. Task steps drive the computer use agent using a machine ID and a task description; they are billed at $0.05 per agent step. Assert steps validate conditions on the current state. Conditional steps (if) branch based on structured conditions. Loop steps repeat a block while a condition holds. Parallel steps execute multiple branches concurrently. The workflow is versioned, idempotent on replay, and can reference variables using the double-brace syntax {{inputs.x}} or stepId.field. The server returns a workflow ID that you can use to start runs, query status, or cancel.
curl -X POST https://coasty.ai/v1/workflows \
-H "X-API-Key: ${COASTY_API_KEY:?COASTY_API_KEY is required}" \
-H "Content-Type: application/json" \
-d '{
"version": 1,
"steps": [
{
"id": "task_login",
"type": "task",
"machine_id": "machine_123",
"task": "Log in to the web app using the email field and the password field."
},
{
"id": "assert_logged_in",
"type": "assert",
"condition": {
"type": "text_matches",
"locator": {"type": "text", "text": "Welcome"}
}
},
{
"id": "if_admin",
"type": "if",
"condition": {
"type": "text_matches",
"locator": {"type": "text", "text": "Admin"}
},
"branch": {
"steps": [
{
"id": "task_admin",
"type": "task",
"machine_id": "machine_123",
"task": "Run the admin dashboard report."
}
]
}
},
{
"id": "loop_items",
"type": "loop",
"condition": {
"type": "text_matches",
"locator": {"type": "text", "text": "Item"}
},
"step": {
"id": "task_item",
"type": "task",
"machine_id": "machine_123",
"task": "Click the item and fill the purchase quantity."
}
},
{
"id": "parallel_actions",
"type": "parallel",
"steps": [
{
"id": "task_payment",
"type": "task",
"machine_id": "machine_123",
"task": "Enter payment details."
},
{
"id": "task_confirm",
"type": "task",
"machine_id": "machine_123",
"task": "Confirm the order."
}
]
}
]
}'Step types and their behavior
- ●Task steps run the computer use agent on a machine_id; each agent step bills $0.05. You can append custom instructions to the base prompt by including an 'instructions' field in the task step.
- ●Assert steps validate the current state against a condition. Conditions support text_matches and other structured checks. If the condition fails, the workflow run enters the failed state.
- ●If steps branch execution based on a condition. The branch structure contains its own 'steps' array that runs only when the condition evaluates to true.
- ●Loop steps repeat an inner block while a condition holds. Each iteration is a separate agent step and is billed $0.05. You can limit iterations with 'max_iterations' if needed.
- ●Parallel steps execute multiple sub-workflows concurrently. Each parallel branch runs on the same machine_id and counts as its own agent steps.
- ●Variables are referenced via double-brace placeholders such as {{inputs.x}} or stepId.field, allowing dynamic values to flow through the workflow.
Each task step is billed $0.05 per agent step, and your workflow version controls the DSL semantics.
Where this beats brittle automation
Traditional APIs require you to know every endpoint and field in advance. UI changes break selectors and break scripts. The Coasty workflow DSL lets you describe the goal in human language, then hand off to an agent that sees the screen and adapts. You can model complex multi-step processes with asserts, loops, and parallel branches without hardcoding selectors. The workflow remains robust even when the UI shifts, because the agent matches text and visual cues rather than brittle IDs.
Use the workflow DSL to orchestrate multi-step, stateful automation on real desktops and browsers. Start a run with POST /v1/workflows, then monitor progress with GET /v1/runs and event streams. Get your API key and start building at https://coasty.ai/developers.