> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/documentation/workflows/stages-and-routes.md).

# Stages and routes

Add stages to a workflow, connect their routes, and set each stage up.

A **stage** is a step in the workflow. A **route** connects one stage's outcome to the next stage. Some stages have one outcome; others, like **Review**, have several, and each needs its own route.

![Workflow graph where Review routes Accepted items to Complete and Rejected items back to Annotate](https://292810646-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGjVLUz4wthGkGlRKM6rM%2Fuploads%2FWzZczVhoXArL8Aj5KtmX%2Fworkflow-graph.webp?alt=media)

## Build a workflow

{% stepper %}
{% step %}

### Open the editor

Open the project and select **Workflows**.
{% endstep %}

{% step %}

### Add stages

Select **Add Stages** and pick a stage type. It appears on the canvas.
{% endstep %}

{% step %}

### Connect routes

Drag from a stage's outcome to the next stage. Connect every outcome, including **Rejected**, **Fail** and **Not evaluated**.
{% endstep %}

{% step %}

### Set up each stage

Select a stage to open its settings panel on the right.
{% endstep %}

{% step %}

### Save and Apply

Select **Save and Apply**. If something is wrong, for example a stage nobody can reach, Unitlab tells you what to fix.
{% endstep %}
{% endstepper %}

![Annotate stage settings panel with the Ontologies tab listing seven robotics classes, next to the Project, Annotate and Review stages](https://292810646-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGjVLUz4wthGkGlRKM6rM%2Fuploads%2Ft173Nl3m9IbJ89fC401h%2Fstage-settings.webp?alt=media)

## Stage reference

| Stage            | What it does                                                                                                                                                      | Outcomes                                         |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| **Project**      | Where items enter. Every workflow has exactly one.                                                                                                                | One route to the first stage.                    |
| **Annotate**     | A person labels the item. Choose the ontology and the annotators.                                                                                                 | One route.                                       |
| **Review**       | A person accepts or rejects the work.                                                                                                                             | **Accepted**, **Rejected**                       |
| **Consensus**    | Several people label the same item on their own; Unitlab compares their answers. Set **Required votes**, **Must agree** and **Answer similarity**. See Consensus. | **Pass**, **Fail** (send Fail to a Review stage) |
| **Quality Gate** | Compares the labels with a hidden answer key. See Quality Gate.                                                                                                   | **Pass**, **Fail**, **Not evaluated**            |
| **Model**        | An AI model labels the item. See Model stages.                                                                                                                    | One route.                                       |
| **Agent**        | Your own service reads and labels the item. See Agent stage.                                                                                                      | One route.                                       |
| **Logic**        | Sends items one way or another based on their labels and attributes. Match **All conditions (AND)** or **Any condition (OR)**.                                    | One route per rule, plus **Else**.               |
| **Sampling**     | Sends a percentage of items, picked at random, one way and the rest another, for example to review 10% of the work.                                               | **Sampled**, **Unsampled**                       |
| **Webhook**      | Sends an event to an HTTPS address you own.                                                                                                                       | **Success**, **Failure**                         |
| **Complete**     | The item is done. Every workflow has exactly one.                                                                                                                 | None                                             |
| **Archive**      | The item is set aside and leaves the work.                                                                                                                        | None                                             |

Each stage also has **Statistics SLA (hours)**: items that wait longer than this are counted as over the limit in the project **Statistics**. The panel's **Stage distribution** shows how many items wait at each stage now.

## Example: check labels against an answer key

```mermaid
flowchart LR
  P[Project] --> A[Annotate]
  A --> Q[Quality Gate]
  Q -->|Pass| R[Review]
  Q -->|Not evaluated| R
  Q -->|Fail| A
  R -->|Accepted| C[Complete]
  R -->|Rejected| A
```

Items that fail the comparison go straight back to the annotator. Items that pass, and items with no answer key, still get a human review.

## Rules the editor checks

* One **Project** stage and one **Complete** stage.
* Every stage can be reached from **Project**.
* Every outcome has a route. **Complete** and **Archive** have none.
* A stage that holds items can't be deleted without deciding where they go.

## Related

Workflows overview · Assignment and stage actions · Change a live workflow
