> For the complete documentation index, see [llms.txt](https://docs.cosmocloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cosmocloud.io/examples-how-to/reusable-flows-subflows.md).

# Reusable Flows - SubFlows

Many a times we need a common business logic to be implemented in multiple APIs and places, and we do not want to build this common logic from scratch every single time.

That's where [SubFlows](/resources/subflows.md) come into the picture, allowing you to define your custom common logic **just once** and then reuse it in multiple APIs or other SubFlows (just like a reusable function).

## Building SubFlows

You can build SubFlows in Cosmocloud, which accepts multiple **arguments** and can return a single **JSON** object - you can use different keys in the JSON object to return multiple objects at once.

{% hint style="info" %}
Checkout how to [create SubFlows here](/resources/subflows.md).
{% endhint %}

## Using [Execute SubFlow](/flow-builder/node-types/external-nodes/execute-subflow.md) Node

You can then use the `Execute SubFlow` node in Cosmocloud's Flow Builder, to call any created SubFlow in the system. You can also pass your arguments to this SubFlow call, as mentioned in the SubFlow documentation.

{% hint style="info" %}
Checkout how to use [Execute SubFlow node](/resources/subflows.md#how-to-use-subflow).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cosmocloud.io/examples-how-to/reusable-flows-subflows.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
