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