Skip to content
中文

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.

FieldSchema typePresence
documentobjectrequired
document.dslstringrequired
document.namespacestringrequired
document.namestringrequired
document.versionstringrequired
document.titlestringoptional
document.summarystringoptional
document.tagsobjectoptional
document.metadataobjectoptional
inputinputoptional
useobjectoptional
use.authenticationsobjectoptional
use.errorsobjectoptional
use.extensionsarrayoptional
use.functionsobjectoptional
use.retriesobjectoptional
use.secretsarrayoptional
use.timeoutsobjectoptional
use.catalogsobjectoptional
dotaskListrequired
timeoutunionoptional
outputoutputoptional
scheduleobjectoptional
schedule.timezonestringoptional
schedule.everydurationoptional
schedule.cronstringoptional
schedule.afterdurationoptional
schedule.oneventConsumptionStrategyoptional
FieldSchema typePresence
dslstringrequired
namespacestringrequired
namestringrequired
versionstringrequired
titlestringoptional
summarystringoptional
tagsobjectoptional
metadataobjectoptional

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.

ValueMeaning
.Previous step output; first step receives workflow input. Transform expressions receive the value at that stage.
input.fromReplaces input after input schema validation.
output.asReplaces task/workflow output before output schema validation.
export.asReplaces $context with the evaluated task output transform.
$contextShared context, initially transformed workflow input.
$workflow.inputOriginal run input.
$inputTransformed task input (raw input while evaluating input.from).
$outputCurrent 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.

FieldSchema typePresence
schemaschemaoptional
fromunionoptional
FieldSchema typePresence
schemaschemaoptional
asunionoptional
FieldSchema typePresence
schemaschemaoptional
asunionoptional
FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional

use

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.

FieldSchema typePresence
authenticationsobjectoptional
errorsobjectoptional
extensionsarrayoptional
functionsobjectoptional
retriesobjectoptional
secretsarrayoptional
timeoutsobjectoptional
catalogsobjectoptional

schedule

Schedule

Use cron or every, with optional IANA timezone (UTC by default). Schedule validation refuses after and on; it is not an event subscription.

FieldSchema typePresence
timezonestringoptional
everydurationoptional
cronstringoptional
afterdurationoptional
oneventConsumptionStrategyoptional
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

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
callstringrequired
withobjectoptional
do:
- callAction:
call: demo/add-one
with: { n: 1 }

run

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
runobjectrequired
run.workflowunionoptional
run.workflow.namespacestringrequired
run.workflow.namestringrequired
run.workflow.versionstringrequired
run.workflow.inputobjectoptional
run.scriptunionoptional
run.script.namespacestringrequired
run.script.namestringrequired
run.script.versionstringrequired
run.script.inputobjectoptional
run.awaitbooleanoptional
withobjectoptional
do:
- child:
run:
script: { namespace: demo, name: summarize, version: "1.0.0", input: { text: hello } }

wait

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
waitdurationrequired
do:
- pause:
wait: { seconds: 1 }

set

set

Outputs the evaluated object or expression. Fields are not automatically merged into input or $context.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
setunionrequired
do:
- value:
set: { greeting: hello }
export: { as: '${ $context + { name: . } }' }

for

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
forobjectrequired
for.eachstringoptional
for.instringrequired
for.atstringoptional
whilestringoptional
dotaskListrequired
do:
- items:
for: { each: item, at: index, in: '${ [1, 2] }' }
do:
- value:
set: { value: '${ $item }', index: '${ $index }' }

fork

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
forkobjectrequired
fork.branchestaskListrequired
fork.competebooleanoptional
do:
- parallel:
fork:
branches:
- first: { set: { value: 1 } }
- second: { set: { value: 2 } }

try

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
trytaskListrequired
catchobjectrequired
catch.errorsobjectoptional
catch.errors.witherrorFilteroptional
catch.asstringoptional
catch.whenstringoptional
catch.exceptWhenstringoptional
catch.retryunionoptional
catch.dotaskListoptional
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

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
switcharrayrequired
do:
- choose:
switch:
- yes: { when: '${ .enabled == true }', then: end }
- otherwise: { then: continue }
- finish: { set: { done: true } }

raise

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
raiseobjectrequired
raise.errorunionrequired
do:
- fail:
raise:
error: { type: "https://example.com/errors/rejected", status: 400, detail: "Review required" }

listen

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.

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
listenobjectrequired
listen.toeventConsumptionStrategyrequired
listen.readdata / envelope / rawoptional
foreachsubscriptionIteratoroptional
do:
- received:
listen:
to:
one:
with: { type: "order.ready" }
read: data

do

do

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).

FieldSchema typePresence
ifstringoptional
inputinputoptional
outputoutputoptional
exportexportoptional
timeoutunionoptional
thenflowDirectiveoptional
metadataobjectoptional
dotaskListrequired
do:
- group:
do:
- value: { set: { ready: true } }

praxis/approval

Call

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

Emit

Not executable: schema validation can accept emit, but run creation refuses it with DEFINITION_INVALID. No output is produced.

Errors

Error · Retry

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.

FieldSchema typePresence
typeunionrequired
statusintegerrequired
instanceunionoptional
titleunionoptional
detailunionoptional
FieldSchema typePresence
whenstringoptional
exceptWhenstringoptional
delaydurationoptional
backoffobjectoptional
backoff.constantobjectrequired
backoff.exponentialobjectrequired
backoff.linearobjectrequired
limitobjectoptional
limit.attemptobjectoptional
limit.attempt.countintegeroptional
limit.attempt.durationdurationoptional
limit.durationdurationoptional
jitterobjectoptional
jitter.fromdurationrequired
jitter.todurationrequired

Serverless Workflow 1.0.3 support matrix

Workflow · Task

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.

ConstructStatusMain fieldsRuntime boundary
documentsupporteddsl, namespace, name, version, title, summary, tags, metadataExecuted by the workflow input/task/output pipeline.
inputsupportedschema, fromExecuted by the workflow input/task/output pipeline.
outputsupportedschema, asExecuted by the workflow input/task/output pipeline.
dosupportedExecuted by the workflow input/task/output pipeline.
timeoutsupportedafterExecuted by the workflow input/task/output pipeline.
usesupportedauthentications, errors, extensions, functions, retries, secrets, timeouts, catalogsNamed errors, retries and timeouts are resolved by the interpreter.
schedulesupportedtimezone, every, cron, after, oncron/every with optional timezone; after/on are refused.
evaluateaccepted-inertExpression-engine selection is not wired; jq is used. Declaration is accepted without runtime resolution.
use.secretsaccepted-inertDeclaration is accepted but Vault/authentication resolution has no runtime effect.
use.authenticationsaccepted-inertDeclaration is accepted but Vault/authentication resolution has no runtime effect.
use.functionsaccepted-inertNo runtime resolver/handler; declaration syntax is accepted.
use.catalogsaccepted-inertNo runtime resolver/handler; declaration syntax is accepted.
use.extensionsaccepted-inertNo runtime resolver/handler; declaration syntax is accepted.
callsupportedif, input, output, export, timeout, then, metadata, call, withSee the task section for output and runtime restrictions.
runsupportedif, 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.inputSee the task section for output and runtime restrictions.
waitsupportedif, input, output, export, timeout, then, metadata, waitSee the task section for output and runtime restrictions.
setsupportedif, input, output, export, timeout, then, metadata, setSee the task section for output and runtime restrictions.
forsupportedif, input, output, export, timeout, then, metadata, for, for.each, for.in, for.at, while, doSee the task section for output and runtime restrictions.
forksupportedif, input, output, export, timeout, then, metadata, fork, fork.branches, fork.competeSee the task section for output and runtime restrictions.
trysupportedif, input, output, export, timeout, then, metadata, try, catch, catch.errors, catch.errors.with, catch.as, catch.when, catch.exceptWhen, catch.retry, catch.doSee the task section for output and runtime restrictions.
switchsupportedif, input, output, export, timeout, then, metadata, switchSee the task section for output and runtime restrictions.
raisesupportedif, input, output, export, timeout, then, metadata, raise, raise.errorSee the task section for output and runtime restrictions.
listensupportedif, input, output, export, timeout, then, metadata, listen, listen.to, listen.read, foreachSee the task section for output and runtime restrictions.
dosupportedif, input, output, export, timeout, then, metadata, doSee the task section for output and runtime restrictions.
emitplannedif, input, output, export, timeout, then, metadata, emit, emit.event, emit.event.withEvent publishing runtime is not wired; run creation refuses emit.
call: httpaccepted-inertResolved as the Action ID http in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration.
call: openapiaccepted-inertResolved as the Action ID openapi in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration.
call: grpcaccepted-inertResolved as the Action ID grpc in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration.
call: asyncapiaccepted-inertResolved as the Action ID asyncapi in praxis, not an upstream protocol transport. This does not activate the upstream protocol-call configuration.
call: a2aaccepted-inertResolved as the Action ID a2a in praxis, not an upstream protocol transport. No built-in Action with that name exists.
call: mcpaccepted-inertResolved as the Action ID mcp in praxis, not an upstream protocol transport. No built-in Action with that name exists.
run.shellnot supported by designOnly saved scripts and workflows execute.
run.containernot supported by designOnly saved scripts and workflows execute.
run.script.codenot supported by designScripts are saved and versioned before reference.
listen.to.allplannedNot executable in the event-wait subset; run creation refuses this form.
listen.read.rawplannedNot executable in the event-wait subset; run creation refuses this form.
listen.foreachplannedNot executable in the event-wait subset; run creation refuses this form.
listen in forkplannedNot executable in the event-wait subset; run creation refuses this form.
approval in forkplannedNot executable in the event-wait subset; run creation refuses this form.
listen dynamic typeplannedNot executable in the event-wait subset; run creation refuses this form.
listen.untilplannedNot executable in the event-wait subset; run creation refuses this form.
schedule.afterplannedSchedule trigger supports cron/every only.
schedule.onplannedSchedule trigger supports cron/every only.

Write a workflow