# Control Flow Bricks

[Release 1.7.0](/release-notes/release-notes-archive/release-1.7.0.md) (June 2022) introduced support for [Control Flow bricks](https://www.pixiebrix.com/marketplace/search/?tags=control-flow) that “control” the order and sequence in which the bricks nested inside them run.

### Types of Control Flow Bricks

There are 4 primary control flow bricks: If-Else, For-Each, Try-Except, and Retry:

* **If-Else**: if a condition is met, run one the “if” branch of bricks, otherwise run the “else” branch of bricks
* **Try-Except**: run a “try” branch of bricks, recovering by running the “catch” branch of bricks if there’s an error or the user cancelled the run
* **Retry**: run a body of bricks, and re-run the body if there’s an error
* **For-Each**: for each element in a list/array, run a body of bricks, providing a different element to the body for each run

The Document Builder also uses control flow for the Button element handler, and the Brick element. The information on this page also applies to bricks you add to those elements.

{% hint style="info" %}
📖 When a Control Flow brick has multiple sub-sequences of bricks, we will call them “branches”. When a Control Flow brick contains a single sequence of bricks, we will call it the “body”.
{% endhint %}

In the Mod Overview, the Control Flow brick appears as a brick with a top/bottom section and one or more branches of bricks:

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

The If-Else brick. If the condition is true, PixieBrix will show confetti. If the condition is false, PixieBrix will show an alert.


---

# 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.pixiebrix.com/developing-mods/developer-concepts/control-flow/control-flow-bricks.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.
