Skip to main content

Sub Workflow Task

"type" : "SUB_WORKFLOW"


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

Use Cases

You can leverage sub-workflow tasks in cases where you want to include another workflow within an existing workflow.


  • The Do-While task does not allow nested Do-While tasks. But it does permit a sub-workflow that can have a Do-While loop inside it.
  • Dynamic Forks can only contain one task. But using the sub-workflow concept, this single task can be a sub-workflow that includes additional tasks.


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



subWorkflowParamMap[String, Any]It includes the parameters name, version, taskToDomain & workflowDefinition. See the below table for detailed info on this.
inputParametersMap[String, Any]The sub workflow’s input can be coupled to the workflow’s input parameters or it can be invoked from the output of the preceding task. For example, if you are taking the sub-workflow’s input parameter from the workflow, then you need to initially add this as an input parameter in the parent workflow (workflow to be called as the sub-workflow). Then you can call the same input parameter inside the sub-workflow definition.


nameStringYou need to map this field with the name of the workflow you are planning to execute.
versionIntegerInclude the version of the workflow to be executed.
taskToDomainMap[String, String]Allows scheduling the sub-workflow's tasks per given mappings. See Task Configurations for instructions to configure taskDomains.
workflowDefinitionWorkflowDefinitionAllows starting a sub-workflow with a dynamic workflow definition.


subWorkflowIdStringSubworkflow execution ID generated when running the sub-workflow

The output of the sub-workflow is also supplied to the output of the workflow.


Imagine that a colleague has created an 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 them into your workflow. However, any updates made by your colleague will not be reflected in your workflow, i.e., you have a "frozen in time" version of the code.

Instead, you 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

This not only makes your workflow more readable, with easier-to-edit JSON, but it will update with the postage_rate workflow.

Codelab Examples

Visualize an example workflow Order Fulfillment, where a sub-workflow is being called within a dynamic fork.