Subflow icon
Log icon

Pass data between subflows (use child flow outputs in a parent flow)

Pass structured data between Kestra subflows. Call a child flow, wait for it, and reuse its outputs to build modular, reusable workflow architectures.

Categories
Core
id: pass-data-between-subflows
namespace: company.team

tasks:
  - id: call_child_flow
    type: io.kestra.plugin.core.flow.Subflow
    namespace: "{{ flow.namespace }}"
    flowId: my_subflow
    wait: true

  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "{{ outputs.call_child_flow.outputs.my_output }}"

Break large pipelines into small, reusable building blocks and pass structured data cleanly from a child flow back to its parent. This blueprint shows the core Kestra pattern for subflow orchestration: a parent flow invokes a child flow, waits for it to finish, and then consumes the child's declared outputs in later tasks. Instead of copy-pasting logic across many pipelines, you encapsulate a unit of work once as a subflow and call it wherever you need it, with explicit data handoffs and full execution visibility.

How it works

  1. The call_child_flow task (io.kestra.plugin.core.flow.Subflow) triggers a child flow. It targets flowId: my_subflow in the same namespace via namespace: "{{ flow.namespace }}", and sets wait: true so the parent blocks until the child execution completes.
  2. The child flow declares typed outputs (for example an output my_output mapped from a task result). Those outputs are returned to the parent once the child finishes.
  3. The log task (io.kestra.plugin.core.log.Log) reads the returned value through {{ outputs.call_child_flow.outputs.my_output }}, demonstrating how downstream tasks consume child outputs.

What you get

  • A working parent/child handoff using Subflow with wait: true.
  • A clear pattern for referencing child outputs via outputs.<taskId>.outputs.<outputId>.
  • A foundation for modular pipelines where shared logic lives in one reusable flow.
  • Independent execution records for parent and child, so each is observable on its own.

Who it's for

  • Data and platform engineers factoring monolithic pipelines into reusable units.
  • Teams standardizing common steps (ingestion, validation, notifications) as shared subflows.
  • Anyone who wants typed, explicit data passing between flows instead of brittle workarounds.

Why orchestrate this with Kestra

Kestra makes flow composition a first-class, declarative concept. You define everything in YAML, get automatic retries on failed tasks, and capture full lineage across parent and child executions. Event triggers can launch the parent on a schedule, a webhook, or an upstream event, and each subflow run is tracked as its own execution with logs and outputs. This is the gap a single script or a standalone scheduler cannot fill: real cross-flow data passing, dependency control with wait: true, and end-to-end observability without custom glue code.

Prerequisites

  • A running Kestra instance.
  • A child flow named my_subflow in the same namespace that declares an output (for example my_output).

Secrets

This blueprint references no secrets. If your child flow connects to external systems, store credentials with {{ secret('NAME') }} rather than hardcoding them.

Quick start

  1. Create a child flow my_subflow in the company.team namespace that produces a typed output such as my_output.
  2. Add this parent flow to the same namespace.
  3. Execute the parent flow.
  4. Inspect the log task output to confirm the child's value was passed back.

How to extend

  • Pass dynamic values into the child by adding inputs to my_subflow and supplying them from the parent.
  • Return multiple typed outputs from the child and consume them across several downstream tasks.
  • Fan out work by calling the subflow inside a ForEach loop over a list.
  • Set wait: false for fire-and-forget child executions when you do not need the result.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.