# Switch (/docs/nodes/switch)



The **Switch** node tests a list of cases in order and follows the **first** one that holds. When none does, it takes the always-present **Default** port.

## When to use it [#when-to-use-it]

* Route by category: product type, customer segment, country group.
* Replace a chain of nested conditions with one readable node.

## How it works [#how-it-works]

<Diagram node="switch" kind="anatomy" />

1. Cases are evaluated top to bottom, each one a boolean expression.
2. The first truthy case wins and its port is taken. The rest are not evaluated.
3. If no case holds, the run takes **Default**.

## Ports [#ports]

| Port              | Taken when                                                               |
| ----------------- | ------------------------------------------------------------------------ |
| One port per case | That case was the first to hold. The port is named after the case label. |
| `Default`         | No case held. Always present and cannot be removed.                      |

## Configuration [#configuration]

| Field | What it does                                            |
| ----- | ------------------------------------------------------- |
| Name  | Label shown on the canvas and in the trace.             |
| Cases | A label and an expression for each case. Order matters. |

## What it writes [#what-it-writes]

No variables. The trace records the matched case (`case_id`, `case_label`), or that the Default branch was taken.

## In a real flow [#in-a-real-flow]

<Diagram node="switch" kind="example" />

A switch on the loan product sends each product to its own rate calculation. Anything unexpected goes to manual review through Default.

## When it fails [#when-it-fails]

* A case expression cannot be evaluated: the run fails with `EXPRESSION_FAILED` and names the case.
* A case without an expression, a duplicated case id or a case named `default` are errors in Checks.

## Good to know [#good-to-know]

* Only **one** path runs. If two things must happen, put them one after the other on the same branch rather than side by side.
* Renaming a case label never rewires the graph; the port keeps its identifier. Deleting a case removes its connection.
* Put the most specific case first: the first match wins.

## Related [#related]

* [Condition](/docs/nodes/condition)
* [Decision table](/docs/nodes/decision-table)
