# Pass data between steps

See how a step picks up the data from the steps above it, using tokens and the Data Selector.

Source: https://support.rework.com/article/pass-data-between-steps

A flow is only useful when the later steps know what the earlier ones found. The email has to greet the person who filled in the form, and the API call has to carry the order number that arrived with the event. Automations handle this with **tokens**: small placeholders you drop into a field, which the app replaces with a real value while the run happens.

## A token names a step and a field

A token looks like this: `{{trigger.body.email}}`. It reads left to right as the step, then the path to the value inside that step's output.

| Token | Reads |
| --- | --- |
| `{{trigger.body.email}}` | The `email` field in the body that arrived with the trigger |
| `{{trigger.body.company}}` | The `company` field from the same body |
| `{{var.lead_score}}` | An automation variable, see [Store values in variables](https://support.rework.com/article/store-values-in-variables) |

Field names that contain spaces or dots use quotes instead of dots: `{{step.rows[0].values["Full name"]}}`.

A whole field that's only a token keeps its type, so a number stays a number rather than turning into text.

## The Data Selector shows what's available

You'll rarely need to type a token yourself. Click into any field that accepts one and the **Data Selector** panel appears, listing every step above this one and the fields each of them produces. Click a field to insert its token where the cursor is.

Inside a field, a token is shown as a chip that names the step and the field, for example **Webhook: body.company**, so you can read a subject line such as _Hot lead: Webhook: body.company_ at a glance.

![The Data Selector listing the fields the trigger produces](https://storage.googleapis.com/reworkv3-public/success/260923/zZTYYcruCo2YlUbqMEWMgM2UmLcuztejmKCSn0jKVF27HPiCg7tLDAdsj0qrjwFd/img.doWbicDdpw8zoU8Xo4yaTrPmaprkvDK8QQUssJ5dYlPmQDdYJ1uP3ZyimDJJXbLh.png)

The panel tells you how much it really knows:

- Real values appear next to the field names once a step has been tested or has run at least once.
  
- **Declared fields** means the step says it will produce those fields, but nothing has run yet, so there's no sample to show. Test the step to see actual values.
  
- A field the sample doesn't contain is still listed, so a value that was simply absent from one event doesn't disappear from the picker.
  

## Test a step to give the ones below it real data

Each time you test a step, its result is pinned as that step's sample. The steps under it then see real values instead of declared names, both in the Data Selector and when you test them. 💡 That's why building a flow works best from the top down: configure and test the trigger, then each step in turn. See [Test a step before you publish](https://support.rework.com/article/test-a-step-before-you-publish).

![A step's output in a finished run](https://storage.googleapis.com/reworkv3-public/success/260923/HDWJunnjrBR8YxLHiBqnOwQ3khMpptlBIIYuqa8wXQPyArxSTnLhgOXRH8hOs5I8/img.4LfycA3ev9DcvMVWaIFd9fi4WFDUVu9tZMVtGosmTIo1jlxqEyAHPm4IGCtCCT6n.png)

> **Note:** Changing a step's settings clears its tested state, and any step that used its output is marked **Not tested** again. A stale sample is worse than none, because it would describe data the step no longer produces.

## When to use a variable instead

Tokens reach backwards to a specific step. When a value has to survive across branches, or be counted up as a loop goes round, store it in an automation variable instead and read it with `{{var.<name>}}`. See [Store values in variables](https://support.rework.com/article/store-values-in-variables).
