Chapter 13
Flows
A collection run sends every request in tree order. A flow is for when the order is yours to set: log in first, read a value out of what it answered, go one way or another on it, run three calls side by side, walk a list one item at a time, and write down what happened. You build it on a canvas, and it is a file in your repository like everything else, flows/<slug>.flow.yaml.
Flows are listed under the collections, in the Flows part of the drawer. New flow… in its + (or in the + beside the environment) asks for a name and opens an empty canvas. The demo workspace comes with one, User onboarding.
13.1The canvas
On a phone a flow has a screen of its own, and runs from top to bottom. 1 runs it, 2 adds a step — pick its kind — and 4 goes back to the requests. Each card, 3, shows what the step is and, after a run, how it went.
The small circle at the bottom of a card is its output port: drag it onto another card to make that one wait for this one, or tap it to add a step after it. An If, a Switch and a Loop have a port for each way out, named above it. Tap a link, or the dot in its middle, to select it, then tap the × that takes the dot’s place to remove it. Hold a finger on an empty spot to open a menu that adds a step there. Drag a card to move it, drag the background to pan, and pinch to zoom.
13.2Kinds of step
| Kind | What it does |
|---|---|
| Request | Sends one of your requests, the way Send sends it. |
| Log | Writes a message into the run — say, which post was made. |
| If | Goes on from true or from false, as a condition holds or not. |
| Switch | Goes on from the case that matches a value, or from default when none does. |
| Loop | Runs the steps after its each port once per item of a list, then goes on from done. |
| Get variable | Reads values out of a response the flow already has, for the steps after it. |
| Set variable | Gives variables a value, for the steps after it. |
Only a request sends anything. The other kinds take no time: each does its work the moment the steps before it are done.
Anywhere a step takes text, {{name}} reads a variable: the environment’s, and anything a step before this one read or set. {{steps.login.status}} is the status the step login answered, and {{steps.login.outcome}} whether it passed, failed or was skipped. A secret never reads in a Log, a Set, a condition or a loop’s list — those are written down, and a secret must not be.
13.3A step
Tap a card to open what it does — in a sheet from the bottom of the screen. Every kind has a name for the canvas and Runs after, the steps it waits for, as chips to switch on and off; one that would close a loop is greyed out, since a flow never runs in a circle.
1 is the step’s last run — for an If, the way it went. An If is three parts: 2 the value to look at, then how it is tested — is not empty, is empty, equals or does not equal — and, for the last two, what to compare it to. Empty means nothing, false, 0 or null; values compare as text. 3 deletes the step, 4 closes the sheet.
The other kinds:
- Request — the request it sends (tap it to pick another), the Expected status — a code such as
201or a class such as2xx; empty, anything below 400 passes — and Keep going if this fails. - Log — the Message. It shows on the card and in the step’s result after a run.
- Switch — the Value, and Cases: each a name on the left, which is the way out of the step, and the text it matches on the right. The first case equal to the value is taken; when none is, default is. Renaming a case keeps its links.
- Loop — Items, a JSON list, usually a value a Get variable step read. The steps after each run once for every item, one item at a time, with
{{item}},{{item.id}}(any path into the item) and{{index}}, from0; the steps after done run once, at the end. An item sees nothing from the one before it. A failure inside stops the loop. - Get variable — the request step to read, From the response of, and Values: a name, and a dotted path into the JSON body —
items.0.idis the first item’sid. The steps after it read each one as{{name}}. - Set variable — names and values; a value may use other variables, as
Page {{page}}does.
13.4Running it
Press Run. Each request shows the status it answered and whether that counts as a pass, an If marks the way it went, and a Log shows what it wrote. Links turn green or red with the step they come from, and while a request waits for an answer, dots move along the link into it. A skipped step is drawn faded.
Every request is sent the way Send sends it: with its collection’s auth and variables, and its own scripts and tests. It fails when it cannot be sent, when a test fails, or when its status is not the one it expects — any status of 400 or more, unless you set another. Inside a loop, a step’s result shows one chip per item.
When a step fails, the steps that wait for it are skipped, and the rest of the flow goes on. A step marked Keep going if this fails does not stop the steps after it, and does not fail the flow. Two steps side by side never see each other’s values, so which one answers first cannot change the result.
13.5The environment it runs in
A flow runs in the environment that is active, unless you choose one for it in the toolbar. A flow with its own environment always uses that one’s variables and secrets — whichever is active — and the choice is saved in the flow file, so a teammate’s run and the worker’s do the same. Values a run read or set stay for the session, the same as values a script sets; a run in a flow’s own environment leaves the active one’s session alone.


