"type": "sub_workflow") runs another workflow as a single step. It has a single handler class, sub_workflow, and takes no process — the workflow it runs is named by the node’s handler_id and handler_version_id.
Use this page when building nodes for Create a Workflow or Update a Workflow.
Node Fields
The
workflowVersionId of the sub-workflow to run. The workflow saves without it, but the node can’t run until it is set, and the pinned version must be active.input_schema, output_schema and mappings work as on any other step — see Variable Schemas. Match them to the sub-workflow’s own input and output variables.
Example
sub-workflow node
Referencing An Existing Workflow
On both Create and Update, a sub-workflow node can point at a workflow that already exists. Sethandler_id (and optionally handler_version_id) to its IDs and the node is saved as is.
Creating Sub-Workflows In The Same Call
Create a Workflow also accepts asubWorkflows map, which creates the sub-workflows together with the workflow that runs them. This is how you copy a workflow and everything it runs into another workspace:
1
Read the workflow with its sub-workflows
Call Get Workflow Details with
include=subWorkflows. The response carries a subWorkflows map of every nested sub-workflow, keyed <workflowId>:<versionId> (latest when the node pins no version).2
Post it back
Send that response to Create a Workflow with a different
x-workspace-id. Opus creates each sub-workflow first, deepest first, then points every sub-workflow node at the new IDs.3
Read the new IDs
The create response’s
subWorkflows map gives the new workflowId and workflowVersionId of each sub-workflow, under the same key you sent.subWorkflows, every sub-workflow node — in the workflow and in each sub-workflow — must have an entry under its <handler_id>:<handler_version_id> key. A missing entry, or a sub-workflow that contains itself, is rejected with 400 before anything is created.
subWorkflows
Update a Workflow does not take
subWorkflows. To change a sub-workflow, update it directly with its own workflowId.