On this page
Sommatic Docs
Open portal

Sub-workflows

Compose workflows from reusable pieces. workflow.chain calls another workflow and can wait for its result; workflow.trigger receives the call, filters callers and passes the data on. Both runs share a correlation id.

View as Markdown
Open in

When the same process shows up in several workflows (validate a document, notify a team, archive a case), build it once as its own workflow and call it from the others. Each piece stays testable and versioned on its own.

The two nodes

NodeWhereWhat it does
workflow.chainIn the callerCalls the target workflow, in sync mode (waits for the result) or async mode (continues at once).
workflow.triggerFirst node of the targetReceives the call, checks the caller and outputs the data it sent.

Configure the call

In workflow.chain:

  • Target Workflow (target_flow_definition_id): the workflow to call, chosen from a list.
  • Payload (payload): the object to send. Use expressions to build it. Leave it empty to forward the node’s input ($json).
  • Execution Mode (execution.mode): sync (default) or async.
  • Timeout (ms) (execution.timeout_ms): in sync mode, how long the call may go without any sign of progress from the target run, 30000 by default.
JSON
{
  "target_flow_definition_id": "<flow-definition-id>",
  "payload": {
    "customer_id": "{{ $('Webhook Receiver').item.json.body.data.customer_id }}",
    "requested_at": "{{ $now.toISO() }}"
  },
  "execution": { "mode": "sync", "timeout_ms": 60000 }
}

Receive the call

The target workflow starts with workflow.trigger. Its output is the payload the caller sent plus a chain_context:

JSON
{
  "customer_id": "cus_xyz789",
  "requested_at": "2026-11-26T10:15:00.000-05:00",
  "chain_context": {
    "caller_flow_definition_id": "…",
    "caller_flow_instance_id": "…",
    "caller_flow_slug": "order-intake",
    "caller_node_id": "…",
    "correlation_id": "chain-…"
  }
}

The next node reads {{ $json.customer_id }}. Accepted Callers (accepted_caller_ids) limits which workflows may call this one; leave it empty to accept any caller. A caller that is not on the list makes the trigger leave through error.

What the caller gets back

workflow.chain leaves through out with:

FieldContent
instance_idThe run of the target workflow.
statusThe final status of the target run in sync mode, or running in async mode.
resultIn sync mode, the target’s result: status, outcome_category, duration_ms, error_summary, metrics and final_output_envelope. null in async mode.
correlation_idThe id shared by both runs.

The target’s last output is at result.final_output_envelope.payload:

JavaScript
{{ $json.result.final_output_envelope.payload.approved }}

Which version runs

The target runs in the same mode as the caller:

  • When the caller is a test run (studio, test webhook), the target runs its draft.
  • When the caller runs a published version, the target runs its default published version. If the target was never published, the call fails with No published version found for the target workflow.

Publish the target before you publish a caller that depends on it.

Traceability

Each call generates a correlation_id that both runs keep. The id of the first run of the chain also travels down every level, so $execution.id points to the root run in every sub-workflow. In the Runs tab, a run that chained into others lists them so you can open each one.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs