All Products
Search
Document Center

CloudFlow:Parallel state

Last Updated:Mar 11, 2026

A Parallel state runs multiple branches at the same time. Use it to split a workflow into concurrent paths -- for example, fetching data from several sources simultaneously or sending notifications through different channels in parallel.

How it works

A Parallel state contains one or more branches, and each branch holds its own sequence of child states. At runtime:

  1. The Parallel state starts all branches concurrently.

  2. Each branch runs its child states independently.

  3. After all branches complete, the Parallel state collects the results into a single map[string]any output. Each branch's result is stored under a key named Branch<Index> (for example, Branch0, Branch1).

  4. If an OutputConstructor is defined, the Parallel state applies it to transform the combined output before passing the result to the next state.

Limits

  • Maximum number of branches per Parallel state: 50

Attributes

Parallel state attributes

AttributeTypeRequiredDescription
NamestringYesState name.
DescriptionstringNoState description.
TypestringYesState type. Set to Parallel.
InputConstructormap[string]anyNoTransforms the input before passing it to the branches. See Inputs and outputs.
BranchesParallelBranch[]YesBranches to run in parallel. See ParallelBranch.
OutputConstructormap[string]anyNoTransforms the combined branch results before passing them to the next state. See State OutputConstructor in "Inputs and outputs".
NextstringNoNext state to run after the Parallel state completes. Not required if End is true.
EndboolNoWhether to end the current scope after the Parallel state completes.
RetryRetryNoRetry policy. See Error handling.
CatchCatchNoCatch policy. See Error handling.

ParallelBranch

ParallelBranch attributes

AttributeTypeRequiredDescription
StatesarrayYesArray of states in the branch.
StartAtstringYesName of the first state to run in the branch.

Example

The following workflow defines a Parallel state named Parallel1 with two branches. Each branch contains a single Pass state that produces a static output.

Type: StateMachine
Name: my-wkfl
SpecVersion: v1
StartAt: Parallel1
States:
  - Type: Parallel
    Name: Parallel1
    End: true
    Branches:
      - StartAt: Pass1
        States:
          - Type: Pass
            Name: Pass1
            End: true
            OutputConstructor:
              FieldA: 123
      - StartAt: Pass2
        States:
          - Type: Pass
            InputConstructor:
              FieldA: 321
            Name: Pass2
            End: true

Branch output

Each branch produces its own output independently:

  • Pass1 output (Branch0):

      {
          "FieldA": 123
      }
  • Pass2 output (Branch1):

      {
          "FieldA": 321
      }

Combined Parallel state output

The Parallel state merges all branch outputs into a single map. Each branch is assigned a default key in the format Branch<Index>:

{
    "Branch0": {
        "FieldA": 123
    },
    "Branch1": {
        "FieldA": 321
    }
}

What's next

  • Inputs and outputs: Transform data flowing through states with InputConstructor and OutputConstructor.

  • Error handling: Configure Retry and Catch policies to handle branch failures.