> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quixa.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Switch (Router) Component

> Multi-branch dynamic routing, condition evaluations, and intelligent DAG branch skipping.

The **Switch (Router)** component introduces conditional multi-branch routing into Quixa workflows. It inspects predecessor status codes, response payloads, or flow variables and dynamically directs execution down matching downstream paths.

***

## 1. Visual Multi-Case Builder

In the **Switch Configuration Dialog**, you can configure multiple discrete routing branches:

* **Branch Label**: A human-readable identifier (e.g. `Payment Approved`, `KYC Required`, `Declined`).
* **Source Expression / Variable**: The target variable to evaluate, such as:
  * `{{PaymentStep.statusCode}}`
  * `{{PaymentStep.response.body.status}}`
  * `{{flowVars.retryCount}}`
* **Comparison Operator**:
  * Numeric & String Equality: `==`, `!=`
  * Numeric Thresholds: `>`, `<`, `>=`, `<=`
  * String Matching: `contains`, `not_contains`, `starts_with`, `ends_with`
  * Nullability: `is_empty`, `is_not_empty`
* **Match Value**: The expected constant or dynamic comparison value.

<Tip>
  Switch can also operate in **Expression Mode**, evaluating raw JavaScript expressions (e.g. `item.totalPrice > 500 && item.currency === 'USD'`).
</Tip>

***

## 2. Dynamic Handles & Color-Coded Badges

For each configured case, the Switch node renders a dedicated, labeled output handle on its right edge:

* `case-0`: Connected to the first matching branch.
* `case-1`, `case-2`...: Subsequent condition branches.
* `default`: An optional fallback handle triggered when no preceding rules evaluate to true.

Connection wires originating from a Switch handle render in vibrant purple (`#8b5cf6`) with dedicated branch badges (`Payment Approved`), making complex routing logic easy to audit visually.

***

## 3. Intelligent DAG Condition Skipping

When the workflow executes:

1. The engine evaluates Switch cases in sequential order until the first match succeeds.
2. Downstream nodes belonging to the matching branch execute normally.
3. Downstream nodes belonging to **unchosen branches** are automatically flagged as `skipKind: "condition"`.
4. **Visual Dimming**: On the canvas, skipped branches immediately dim to **35% opacity and 95% grayscale**, giving operators immediate visual clarity on execution flow.

```mermaid theme={null}
graph LR
    Auth["🔐 Auth Step"] --> Router{"🔀 Switch Router"}
    Router -- "200 OK" --> Profile["👤 Fetch Profile"]
    Router -- "401 / 403" --> RefreshToken["🔄 Refresh Token"]
    Router -- "Default" --> Alert["🚨 Send Slack Alert"]
```

***

## 4. Convergent Downstream Nodes

If multiple branches converge back into a shared downstream node (e.g. an audit log step):

* The engine guarantees that the convergent node executes as long as at least **one active branch** reaches it.
* Unchosen skipped branches do not block the shared node.

***

## 5. Enterprise Decision Tree Patterns

### Threshold-Based Approval Routing

Route requests dynamically based on transaction size or risk score:

* **Case 1 (`Amount < 50,000`)**: Routes directly to `POST /transfers/auto-approve` (Instant STP execution).
* **Case 2 (`Amount >= 50,000`)**: Routes to `POST /compliance/queue-review` (Manual officer review).
* **Default**: Routes to `POST /risk/flag-suspicious`.

During runtime, the unchosen branches immediately gray out on the canvas, providing instant visual diagnostic proof of compliance routing without digging through server logs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.