Skip to main content

Sub Workflow Task

"type" : "SUB_WORKFLOW"


Sub Workflow task allows for nesting a workflow within another workflow.

Use Cases

Suppose we want to include another workflow inside our current workflow. In that case, Sub Workflow Task would be used.


  • The Do-While Task does not allow nested Do-While tasks. But it does permit a subworkflow that can have a Do-While loop inside it.
  • Dynamic Forks can only contain one task. But that one task can be a subworkflow containing many additional tasks.


Sub Workflow task is defined directly inside the workflow with "SUB_WORKFLOW".



subWorkflowParamMap[String, Any]See below
inputParametersMap[String, Any]The task inputParameters become the input parameters for the workflow.


nameStringName of the workflow to execute
versionIntegerVersion of the workflow to execute
taskToDomainMap[String, String]Allows scheduling the sub workflow's tasks per given mappings. See Task Configurations for instructions to configure taskDomains.
workflowDefinitionWorkflowDefinitionAllows starting a subworkflow with a dynamic workflow definition.


subWorkflowIdStringSubworkflow execution Id generated when running the subworkflow

The output of the workflow is also supplied in the output of the subworkflow.


Imagine that a colleague has created a address verification workflow:

example workflow

If you wanted to add this functionality to another workflow, it would be possible to copy all 201 lines of JSON and insert it into your workflow. However, any updates made by your colleague will not be reflected in your workflow - you have a "frozen in time" version of the code.

Instead, we can call the existing workflow as a SUB_WORKFLOW task.

"name": "postage_rate_subworkflow",
"taskReferenceName": "postage_rate_subworkflow_ref",
"inputParameters": {},
"type": "SUB_WORKFLOW",
"decisionCases": {},
"defaultCase": [],
"forkTasks": [],
"startDelay": 0,
"subWorkflowParam": {
"name": "shipping_rate",
"version": 1
"joinOn": [],
"optional": false,
"defaultExclusiveJoinTask": [],
"asyncComplete": false,
"loopOver": []

example workflow with subworkflow

Not only is your workflow more readable, with easier to edit JSON, but it will update with the postage_rate workflow.

Codelab Examples

  • Order Fulfillment: Dynamic tasks can have only one task per fork, but a SubWorkflow is allowed allowing for many tasks to be run.