> For the complete documentation index, see [llms.txt](https://sevenval.gitbook.io/flat/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sevenval.gitbook.io/flat/reference/actions/sub-flow.md).

# sub-flow Action

To better organize or reuse your [flow](/flat/reference/flow.md) code, you can split it into separate files. The `sub-flow` action executes the flow file referenced in its `src="…"` attribute.

## Usage

Normally, a sub flow runs until all its instruction have been executed. Then, control is handed over to the parent flow again.

You can return at any point in your sub flow with a (usually conditional) [`<return/>` statement](/flat/reference/flow.md#return).

The [`<break/>` statement](/flat/reference/flow.md#break) terminates all flows. The parent flow will not be continued. Terminating actions like [`dump`](/flat/reference/actions/dump.md) or [`echo`](/flat/reference/actions/echo.md) terminate the whole request, too.

## Example

```markup
<flow>
  <sub-flow src="my-sub-flow.xml"/>
  …
</flow>
```

`my-sub-flow.xml`:

```markup
<flow>
  <if test="…">
    <sub-flow src="my-sub-sub-flow.xml"/>
    <return/>
  </if>
  …
</flow>
```

The `src` file is resolved relatively to the calling flow file.
