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

# Switch

> Multi-way routing: resolve an expression and run the first case whose value matches (else default). Cleaner than a nested control.if chain for routing an item to one of N pipelines by a discriminator field like a document type.

`control.switch`: Multi-way routing: resolve an expression and run the first case whose value matches (else default). Cleaner than a nested control.if chain for routing an item to one of N pipelines by a discriminator field like a document type.

## Configuration

Configuration fields sit at the step level (not inside `with:`).

<ParamField path="on" type="string" required>
  Template expression whose resolved value selects the case, e.g. "\{\{ doc.type }}".
</ParamField>

<ParamField path="cases" type="array<object>" required>
  Ordered cases; the first whose `when` matches runs. Each case has its own `steps`.

  <Expandable title="cases properties">
    <ParamField path="when" type="string | number | boolean" required>
      Value matched (string-compared) against the resolved `on` value.
    </ParamField>
  </Expandable>
</ParamField>

## Output

<ResponseField path="matched" type="string | number | boolean | null" required>
  The `when` value that matched, or null when the default (or no) branch ran.
</ResponseField>

<ResponseField path="branch" type="&#x22;case&#x22; | &#x22;default&#x22; | &#x22;none&#x22;" required>
  Which branch executed.
</ResponseField>

<ResponseField path="result" type="unknown" required>
  Output from the executed branch (its last step).
</ResponseField>
