Workflow syntax reference
Use this reference to write workflow YAML. The DSL is pinned to 1.0.3; schema acceptance alone does not guarantee runtime support. Examples are complete workflows or do fragments: add the document header below to fragments. Action and child references must exist in your account before execution.
Workflow and document
Serverless Workflow 1.0.3 · document
document: dsl: "1.0.3" namespace: docs-samples name: example version: "1.0.0"input: schema: format: json document: { type: object }do: - ready: { set: { ready: true } }document requires dsl, namespace, name and an exact semver version. Root do is required. timeout may be inline (after: { seconds: 30 }) or a name in use.timeouts. Metadata does not change execution.
| Field | Schema type | Presence |
|---|---|---|
document | object | required |
document.dsl | string | required |
document.namespace | string | required |
document.name | string | required |
document.version | string | required |
document.title | string | optional |
document.summary | string | optional |
document.tags | object | optional |
document.metadata | object | optional |
input | input | optional |
use | object | optional |
use.authentications | object | optional |
use.errors | object | optional |
use.extensions | array | optional |
use.functions | object | optional |
use.retries | object | optional |
use.secrets | array | optional |
use.timeouts | object | optional |
use.catalogs | object | optional |
do | taskList | required |
timeout | union | optional |
output | output | optional |
schedule | object | optional |
schedule.timezone | string | optional |
schedule.every | duration | optional |
schedule.cron | string | optional |
schedule.after | duration | optional |
schedule.on | eventConsumptionStrategy | optional |
| Field | Schema type | Presence |
|---|---|---|
dsl | string | required |
namespace | string | required |
name | string | required |
version | string | required |
title | string | optional |
summary | string | optional |
tags | object | optional |
metadata | object | optional |
Data flow
Input · Output · Export · Schema
Expressions are jq, evaluated only when the whole string is ${ … }. Always quote them in YAML, including inline maps; use single quotes around an expression containing object braces. Other strings are literals, not interpolation. A missing object field evaluates to null. Omit optional fields instead of sending null.
| Value | Meaning |
|---|---|
. | Previous step output; first step receives workflow input. Transform expressions receive the value at that stage. |
input.from | Replaces input after input schema validation. |
output.as | Replaces task/workflow output before output schema validation. |
export.as | Replaces $context with the evaluated task output transform. |
$context | Shared context, initially transformed workflow input. |
$workflow.input | Original run input. |
$input | Transformed task input (raw input while evaluating input.from). |
$output | Current task output; final data during root output.as. |
To save a result while retaining existing context, use export: { as: '${ $context + { name: . } }' } and read it later with '${ $context.name }'。
Schemas must be inline JSON Schema: schema: { format: json, document: { type: object } }. External schema resources are not fetched at runtime.
| Field | Schema type | Presence |
|---|---|---|
schema | schema | optional |
from | union | optional |
| Field | Schema type | Presence |
|---|---|---|
schema | schema | optional |
as | union | optional |
| Field | Schema type | Presence |
|---|---|---|
schema | schema | optional |
as | union | optional |
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
use
errors, retries and timeouts define named reusable runtime values. secrets and authentications are syntax declarations only: runtime Vault/authentication resolution is unavailable. functions, catalogs, extensions and root evaluate do not install a function catalog, extension handler or expression engine. Use Action IDs and jq instead.
| Field | Schema type | Presence |
|---|---|---|
authentications | object | optional |
errors | object | optional |
extensions | array | optional |
functions | object | optional |
retries | object | optional |
secrets | array | optional |
timeouts | object | optional |
catalogs | object | optional |
schedule
Use cron or every, with optional IANA timezone (UTC by default). Schedule validation refuses after and on; it is not an event subscription.
| Field | Schema type | Presence |
|---|---|---|
timezone | string | optional |
every | duration | optional |
cron | string | optional |
after | duration | optional |
on | eventConsumptionStrategy | optional |
document: dsl: "1.0.3" namespace: docs-samples name: example version: "1.0.0"schedule: { cron: "0 9 * * *", timezone: Asia/Shanghai }do: - ready: { set: { ready: true } }call
Calls an Action. call is namespace/name; a bare name resolves to praxis. with supplies arguments and defaults to {}. Output is the Action result. Built-in Actions can use praxis/.... This does not execute upstream HTTP, OpenAPI, gRPC, AsyncAPI, A2A or MCP protocol calls.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
call | string | required |
with | object | optional |
do: - callAction: call: demo/add-one with: { n: 1 }run
Runs a saved script or workflow. run.script and run.workflow accept ns/name@range or {namespace, name, version, input}. Object input defaults to {}; string references use task-level with. await defaults to true and returns the child output; false returns {run_id}. Inline scripts, shell and container execution are outside this runtime.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
run | object | required |
run.workflow | union | optional |
run.workflow.namespace | string | required |
run.workflow.name | string | required |
run.workflow.version | string | required |
run.workflow.input | object | optional |
run.script | union | optional |
run.script.namespace | string | required |
run.script.name | string | required |
run.script.version | string | required |
run.script.input | object | optional |
run.await | boolean | optional |
with | object | optional |
do: - child: run: script: { namespace: demo, name: summarize, version: "1.0.0", input: { text: hello } }wait
Pauses for a duration and preserves the input as output. Use nonnegative days, hours, minutes, seconds and milliseconds, or a duration such as PT1S. Do not use calendar year or month units.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
wait | duration | required |
do: - pause: wait: { seconds: 1 }set
Outputs the evaluated object or expression. Fields are not automatically merged into input or $context.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
set | union | required |
do: - value: set: { greeting: hello } export: { as: '${ $context + { name: . } }' }for
Iterates sequentially over an array or object values. each defaults to item and at to index (zero-based); access them as $item and $index. while must be true before each iteration. Output is the last iteration output, or unchanged input for an empty collection; results are not collected into an array.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
for | object | required |
for.each | string | optional |
for.in | string | required |
for.at | string | optional |
while | string | optional |
do | taskList | required |
do: - items: for: { each: item, at: index, in: '${ [1, 2] }' } do: - value: set: { value: '${ $item }', index: '${ $index }' }fork
Executes branches concurrently. compete defaults to false and outputs an array in branch order; true takes the first successful branch output. Branches cannot listen or request approval. At most 10 branches and a nested fan-out of 25.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
fork | object | required |
fork.branches | taskList | required |
fork.compete | boolean | optional |
do: - parallel: fork: branches: - first: { set: { value: 1 } } - second: { set: { value: 2 } }try
Executes the try list. catch uses errors.with for static equality on error fields; as defaults to error, when/exceptWhen control matching, and do handles recovery. retry is inline or names use.retries and supports delay, backoff, jitter, limit and when/exceptWhen. attempt.count excludes the initial execution; attempt.duration limits each retry and limit.duration starts at the first failure. Output is the final successful or recovery-list output. Unmatched errors propagate.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
try | taskList | required |
catch | object | required |
catch.errors | object | optional |
catch.errors.with | errorFilter | optional |
catch.as | string | optional |
catch.when | string | optional |
catch.exceptWhen | string | optional |
catch.retry | union | optional |
catch.do | taskList | optional |
do: - guarded: try: - fail: raise: error: { type: "https://example.com/errors/rejected", status: 400 } catch: as: error retry: delay: { seconds: 1 } limit: { attempt: { count: 1 } } do: - recover: { set: { recovered: true } }switch
Selects the first branch whose when is true; a branch without when is the fallback. then is continue, end, exit or a task name in the same list. Output preserves input; branches are flow directives, not task lists.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
switch | array | required |
do: - choose: switch: - yes: { when: '${ .enabled == true }', then: end } - otherwise: { then: continue } - finish: { set: { done: true } }raise
Raises an inline error or a name in use.errors, requiring type and status; title and detail are preserved. Produces no normal output and can be caught by try/catch.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
raise | object | required |
raise.error | union | required |
do: - fail: raise: error: { type: "https://example.com/errors/rejected", status: 400, detail: "Review required" }listen
Supports to.one or to.any with 1–8 filters, outside forks only. with.type must be a literal string; optional source/subject are literal strings and data may be a jq boolean expression. read defaults to data and outputs event data; envelope outputs the full event. to.all, until, foreach, raw and dynamic type cannot execute. timeout may be inline or name use.timeouts.
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
listen | object | required |
listen.to | eventConsumptionStrategy | required |
listen.read | data / envelope / raw | optional |
foreach | subscriptionIterator | optional |
do: - received: listen: to: one: with: { type: "order.ready" } read: datado
Executes named tasks sequentially and outputs the last task output. Names must be unique within a list. Each task has exactly one kind (for also has do).
| Field | Schema type | Presence |
|---|---|---|
if | string | optional |
input | input | optional |
output | output | optional |
export | export | optional |
timeout | union | optional |
then | flowDirective | optional |
metadata | object | optional |
do | taskList | required |
do: - group: do: - value: { set: { ready: true } }praxis/approval
call: praxis/approval is a built-in asynchronous function, not an Action. Its with is validated before opening a human task; the workflow waits for settlement and uses the outcome as step output. It cannot run in fork branches. See the approval guide for the complete input and outcome contract.
emit
Not executable: schema validation can accept emit, but run creation refuses it with DEFINITION_INVALID. No output is produced.
Errors
Catch matches the full type URI and other fields exactly. Standard types use https://serverlessworkflow.io/spec/1.0.0/errors/ followed by validation, expression, configuration, authentication, authorization, communication, timeout or runtime. The error has type, status and instance (task pointer), with optional title, detail, code, request_id, errors and upstream. Custom raise preserves its type URI. Service budget/depth failures use BUDGET_EXCEEDED / DEPTH_LIMIT_EXCEEDED, and deadlines use TIMEOUT; hard run limits and workflow deadlines cannot be bypassed by catch.
Validation responses contain errors[]: each entry has pointer (JSON Pointer or source line/column path), detail (what failed), and optional hint (repair advice). Read the first entry, fix it and validate again.
| Field | Schema type | Presence |
|---|---|---|
type | union | required |
status | integer | required |
instance | union | optional |
title | union | optional |
detail | union | optional |
| Field | Schema type | Presence |
|---|---|---|
when | string | optional |
exceptWhen | string | optional |
delay | duration | optional |
backoff | object | optional |
backoff.constant | object | required |
backoff.exponential | object | required |
backoff.linear | object | required |
limit | object | optional |
limit.attempt | object | optional |
limit.attempt.count | integer | optional |
limit.attempt.duration | duration | optional |
limit.duration | duration | optional |
jitter | object | optional |
jitter.from | duration | required |
jitter.to | duration | required |
Serverless Workflow 1.0.3 support matrix
supported means executable support. planned means refused today. not supported by design means intentionally refused. accepted-inert means currently accepted, but without runtime effect (planned support). In particular, use.secrets / use.authentications do not resolve secrets or authentication. call: a2a / call: mcp resolve as an Action named a2a / mcp in praxis, which does not exist; they do not invoke a protocol runtime. The table also lists the other currently accepted declarations and protocol-looking Action names explicitly.
| Construct | Status | Main fields | Runtime boundary |
|---|---|---|---|
| document | supported | dsl, namespace, name, version, title, summary, tags, metadata | Executed by the workflow input/task/output pipeline. |
| input | supported | schema, from | Executed by the workflow input/task/output pipeline. |
| output | supported | schema, as | Executed by the workflow input/task/output pipeline. |
| do | supported | Executed by the workflow input/task/output pipeline. | |
| timeout | supported | after | Executed by the workflow input/task/output pipeline. |
| use | supported | authentications, errors, extensions, functions, retries, secrets, timeouts, catalogs | Named errors, retries and timeouts are resolved by the interpreter. |
| schedule | supported | timezone, every, cron, after, on | cron/every with optional timezone; after/on are refused. |
| evaluate | accepted-inert | Expression-engine selection is not wired; jq is used. Declaration is accepted without runtime resolution. | |
| use.secrets | accepted-inert | Declaration is accepted but Vault/authentication resolution has no runtime effect. | |
| use.authentications | accepted-inert | Declaration is accepted but Vault/authentication resolution has no runtime effect. | |
| use.functions | accepted-inert | No runtime resolver/handler; declaration syntax is accepted. | |
| use.catalogs | accepted-inert | No runtime resolver/handler; declaration syntax is accepted. | |
| use.extensions | accepted-inert | No runtime resolver/handler; declaration syntax is accepted. | |
| call | supported | if, input, output, export, timeout, then, metadata, call, with | See the task section for output and runtime restrictions. |
| run | supported | if, input, output, export, timeout, then, metadata, run, run.workflow, run.workflow.namespace, run.workflow.name, run.workflow.version, run.workflow.input, run.script, run.script.namespace, run.script.name, run.script.version, run.script.input | See the task section for output and runtime restrictions. |
| wait | supported | if, input, output, export, timeout, then, metadata, wait | See the task section for output and runtime restrictions. |
| set | supported | if, input, output, export, timeout, then, metadata, set | See the task section for output and runtime restrictions. |
| for | supported | if, input, output, export, timeout, then, metadata, for, for.each, for.in, for.at, while, do | See the task section for output and runtime restrictions. |
| fork | supported | if, input, output, export, timeout, then, metadata, fork, fork.branches, fork.compete | See the task section for output and runtime restrictions. |
| try | supported | if, input, output, export, timeout, then, metadata, try, catch, catch.errors, catch.errors.with, catch.as, catch.when, catch.exceptWhen, catch.retry, catch.do | See the task section for output and runtime restrictions. |
| switch | supported | if, input, output, export, timeout, then, metadata, switch | See the task section for output and runtime restrictions. |
| raise | supported | if, input, output, export, timeout, then, metadata, raise, raise.error | See the task section for output and runtime restrictions. |
| listen | supported | if, input, output, export, timeout, then, metadata, listen, listen.to, listen.read, foreach | See the task section for output and runtime restrictions. |
| do | supported | if, input, output, export, timeout, then, metadata, do | See the task section for output and runtime restrictions. |
| emit | planned | if, input, output, export, timeout, then, metadata, emit, emit.event, emit.event.with | Event publishing runtime is not wired; run creation refuses emit. |
| call: http | accepted-inert | Resolved as the Action ID http in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration. | |
| call: openapi | accepted-inert | Resolved as the Action ID openapi in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration. | |
| call: grpc | accepted-inert | Resolved as the Action ID grpc in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration. | |
| call: asyncapi | accepted-inert | Resolved as the Action ID asyncapi in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration. | |
| call: a2a | accepted-inert | Resolved as the Action ID a2a in praxis, not an upstream protocol transport. No built-in Action with that name exists. | |
| call: mcp | accepted-inert | Resolved as the Action ID mcp in praxis, not an upstream protocol transport. No built-in Action with that name exists. | |
| run.shell | not supported by design | Only saved scripts and workflows execute. | |
| run.container | not supported by design | Only saved scripts and workflows execute. | |
| run.script.code | not supported by design | Scripts are saved and versioned before reference. | |
| listen.to.all | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| listen.read.raw | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| listen.foreach | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| listen in fork | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| approval in fork | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| listen dynamic type | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| listen.until | planned | Not executable in the event-wait subset; run creation refuses this form. | |
| schedule.after | planned | Schedule trigger supports cron/every only. | |
| schedule.on | planned | Schedule trigger supports cron/every only. |