To create a workflow, you define the desired steps and order of execution using the Workflows syntax. Every workflow must have at least one step. The step name can include any alphanumeric character as well as underscores.
By default, Workflows treats steps as if they are in an ordered list and executes them one at a time until all the steps have run. For example, this workflow has two steps:
YAML
- STEP_NAME_A: ... - STEP_NAME_B: ...
JSON
[ { "STEP_NAME_A": { ... } }, { "STEP_NAME_B": { ... } }, ]
Workflows supports various types of steps, including the following:
- Assign a variable
- Apply conditions
- Invoke an HTTP endpoint
- Execute workflow steps in parallel
- Return a value
- Pause a workflow
Main workflow
As a best practice, we recommend placing your main workflow in a main
block.
If a workflow has a subworkflow,
the main workflow must be placed in a main
block. Similarly, for a workflow
to receive runtime arguments there
must be a main
block.
YAML
main: params: [MAP_NAME] steps: - STEP_NAME: ... ...
JSON
{ "main": { "params": [ "MAP_NAME" ], "steps": [ { "STEP_NAME": { ... } }, ... ] } }
Implicit step ordering
This sample shows implicit step ordering within a workflow. By default, the steps of a workflow are executed in the order they appear in the workflow definition.
YAML
JSON
Nested steps
You can use a steps
block to nest a series of steps and further define a
workflow:
YAML
- STEP_NAME: steps: - STEP_NAME_1: steps: - STEP_NAME_A: ... - STEP_NAME_B: ... - STEP_NAME_2: steps: - STEP_NAME_C: ...
JSON
{ STEP_NAME: { "steps": [ { STEP_NAME_1: { "steps": [ { STEP_NAME_A: ... }, { STEP_NAME_B: ... } ] } }, { STEP_NAME_2: { "steps": [ { STEP_NAME_C: ... } ] } } ] } }
Variables declared in a steps
block have workflow-level scope and can be
accessed outside of the block. Any step type can be nested inside of a steps
block including assign
, call
, and switch
. For example:
YAML
main: steps: - series_one: steps: - step_a: call: http.get args: url: https://host.com/api1 result: api_response1 - step_b: assign: - varA: "Monday" - varB: "Tuesday" - series_two: steps: - step_c: call: http.get args: url: https://host.com/api2 result: api_response2 - step_d: assign: - varC: "Wednesday" - varD: "Thursday"
JSON
{ "main": { "steps": [ { "series_one": { "steps": [ { "step_a": { "call": "http.get", "args": { "url": "https://host.com/api1" }, "result": "api_response1" } }, { "step_b": { "assign": [ { "varA": "Monday" }, { "varB": "Tuesday" } ] } } ] } }, { "series_two": { "steps": [ { "step_c": { "call": "http.get", "args": { "url": "https://host.com/api2" }, "result": "api_response2" } }, { "step_d": { "assign": [ { "varC": "Wednesday" }, { "varD": "Thursday" } ] } } ] } } ] } }
Note that in some cases, steps
is required; for example, when defining a
subworkflow or a for loop.