# Workflow.branch()
[EN] Source: https://mastra.ai/reference/workflows/workflow-methods/branch

The `.branch()` method creates conditional branches between workflow steps, allowing for different paths to be taken based on the result of a previous step.

## Usage example

```typescript copy
workflow.branch([
  [async ({ context }) => true, step1],
  [async ({ context }) => false, step2],
]);
```

## Parameters

<PropertiesTable
  content={[
    {
      name: "steps",
      type: "[() => boolean, Step]",
      description:
        "An array of tuples, each containing a condition function and a step to execute if the condition is true",
      isOptional: false,
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "workflow",
      type: "NewWorkflow",
      description: "The workflow instance for method chaining",
    },
  ]}
/>

## Related

- [Conditional Branching Logic](/docs/workflows/control-flow#conditional-logic-with-branch)
- [Conditional Branching Example](/examples/workflows_legacy/conditional-branching)


---
title: "Reference: Workflow.commit() | Workflows"
description: Documentation for the `Workflow.commit()` method in workflows, which finalizes the workflow and returns the final result.
---