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

# Flow

> The components that start, end and redirect a workflow: flow.start, flow.end and flow.goto.

The flow components are the steps that give an execution its shape. Every execution begins at one `flow.start`,
ends at a `flow.end`, and may jump between steps with a `flow.goto`. They carry no data and take no provider.

```mermaid theme={null}
graph LR
    Start([flow.start]) --> Step[any component]
    Step --> End([flow.end])
```

## `flow.start`

The entry point of an execution. Each definition holds exactly one. It has no flow input, so nothing leads to it, and
it takes its `success` route as soon as it runs.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `success` | Flow output | — | Taken as soon as the execution starts. Wire it to the first step. |

A definition with no `flow.start` fails [its check](https://docs.blobhub.io/blob-types/workflow/operations/check-definition.md), and so does one
with several. A `flow.start` is never reported as unreachable.

* `` `flow.start` component is not found. Execution does not have a starting point ``
* ``More than one `flow.start` component is found. Execution does not have a clear starting point``

## `flow.end`

A terminal step. When the execution enters a `flow.end`, it finishes, and nothing after it runs. It has only a flow
input, so it has no routes to configure and no Route table. A `flow.end` needs no outbound connection.

## `flow.goto`

A jump. A `flow.goto` passes control to another `flow.goto` that is not at the end of one of its connections, so a flow
can loop back or skip ahead without a line drawn across the editor. One `flow.goto` marks the spot with a `self_alias`,
and another jumps to it with the same name as its `goto_alias`.

| Route | Category | Value | Notes |
| :- | :- | :- | :- |
| `success` | Flow output | — | The connection the step follows, when one leaves it ([Connection first](#connection-first)). |
| `self_alias` | Data input | `text` | The name this `flow.goto` answers to. A jump lands on the first `flow.goto` in the definition whose `self_alias` equals its `goto_alias`. |
| `goto_alias` | Data input | `text` | The `self_alias` of the `flow.goto` to jump to. |

### Connection first

A `flow.goto` with a connection leaving its flow output follows that connection, whatever its `goto_alias` says. A
`goto_alias` is read only when nothing leaves the step. The `flow.goto` it names is entered next, as if a connection led
to it, and the execution posts a `component.output` event, `Redirecting to alias "<goto_alias>"`.

A `flow.goto` that has a `self_alias` and no `goto_alias` is a landing point. It is entered by a jump, and then follows
its own connection to the steps after it. The same `flow.goto` may carry both aliases.

### When a jump cannot land

A `flow.goto` that has no connection and no `goto_alias` posts a `component.error` event, `"goto_alias" input is not
specified`. One whose `goto_alias` names no `flow.goto` posts `"goto_alias" value leads nowhere`. Either takes the
step's `failure` route. A `flow.goto` has no `failure` route, so the execution fails with `Desired route ("failure") is
not satisfied in the workflow definition`.

A `flow.goto` with neither a `goto_alias` nor a `self_alias` fails the definition's check with
``Either one of `goto_alias` or `self_alias` must be specified``. A `flow.goto` is never reported for having
nowhere to proceed, or for being unreachable, since a jump is how it is reached and left.

### Example: retry a step

Corvel Freight books a carrier in a `logic.code`, which can fail when the carrier's slot is taken. A `flow.goto` named
`Book carrier` is the landing point: its `self_alias` is `book_carrier`, and its `success` leads to the booking step.
Another `flow.goto`, `Retry booking`, has the `goto_alias` `book_carrier` and nothing leaving it. The booking step's
`failure` route leads to `Retry booking`, which sends the execution back to the landing point. The booking step's
code counts attempts in a `data.integer`, so the loop ends when it takes `success` or gives up.

```json theme={null}
{
  "components": [
    {"id": "land", "category": "flow", "type": "flow.goto", "name": "Book carrier",
     "position": {"x": 200, "y": 0},
     "ports": [{"category": "data_input", "route": "self_alias", "value": {"type": "text", "text": "book_carrier"}}]},
    {"id": "retry", "category": "flow", "type": "flow.goto", "name": "Retry booking",
     "position": {"x": 600, "y": 200},
     "ports": [{"category": "data_input", "route": "goto_alias", "value": {"type": "text", "text": "book_carrier"}}]}
  ],
  "connections": [
    {"id": "c1", "source_id": "land", "target_id": "<booking step>", "source_port": "flow_output",
     "target_port": "flow_input", "route": "success"},
    {"id": "c2", "source_id": "<booking step>", "target_id": "retry", "source_port": "flow_output",
     "target_port": "flow_input", "route": "failure"}
  ]
}
```

`Retry booking` has no connection, so it reads its `goto_alias`. Add a connection to it and the jump is never made.


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