# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
