> 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/resources/subflows.md).

# SubFlows

SubFlow in cosmocloud provides modular approach to build reusable piece of flow. It helps you to build a piece of code once and plug it in existing flow.

## Create SubFlow

* Navigate to **Application Layer -> SubFlows** in your Cosmocloud project.
* Click on **Create SubFlow** button
* Add your SubFlow name as well as add the **Arguments** your SubFlow will receive from the calling Flow (an API or other SubFlow).

## Understanding Arguments

<figure><img src="/files/Px5SAPczMcNI4SLoJDou" alt=""><figcaption></figcaption></figure>

* **Toggle :** This is used to mark if argument is `required` or `optional`
* **Argument key :** argument name to be received
* **Argument type :** It specify what type of value is expected
* **Default :** It specify default value if user didn't enter value. (optional)

## How to use SubFlow

SubFlow in cosmocloud is an isolated component which means  every value that you want to access in SubFlow needs to passed as an argument.

#### Understanding SubFlow node

* To execute this SubFlow in an existing API, you can use `Execute SubFlow` node&#x20;

<figure><img src="/files/ACxWgEcDdL94YOA4R9Iv" alt=""><figcaption></figcaption></figure>

* You need to select the SubFlow which you need to execute and also pass required arguments.

<figure><img src="/files/J1JghaqiByvfc11UFK7l" alt=""><figcaption></figcaption></figure>

* Arguments will be passed in as keys and values. These values are case sensitive so make sure enter correct terms.

<figure><img src="/files/YMb7gVsCbJOLONHuDUrN" alt=""><figcaption></figcaption></figure>


---

# 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/resources/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.
