# Input Data

> The data that reached the current node.

Source: https://docs.sommatic.ai/en/expressions/reference/input-data/

Each example was run against the deployed expression engine over the [example context](#example-context) at the end of the page.

## `$json`

Variable · `object` · Source: `Sommatic AI expression engine`

```javascript
$json
```

The output of the node that routed to the current one. For the first node after a trigger, it is what the trigger delivered: a webhook trigger delivers the request as `{ body, headers, query, method }`. When several branches join into one node, `$json` is the output of the branch that arrived last; the [`flow.join`](https://docs.sommatic.ai/en/nodes/flow.join/) node is the way to combine branches.

`$json` changes from node to node. To read something from a node further back, use [`$('Node label')`](https://docs.sommatic.ai/en/expressions/reference/node-reference/#node-accessor).

### Examples

```javascript
{{ $json.body.email }}
```

Result (string):

```json
"ana.perez@example.com"
```

```javascript
{{ $json.body.items.length }}
```

Result (number):

```json
3
```

```javascript
{{ $json.headers['content-type'] }}
```

Result (string):

```json
"application/json"
```

A field that may be missing: optional chaining returns undefined instead of failing.

```javascript
{{ $json.body.customer?.phone }}
```

Result (undefined):

```json
undefined
```

### Errors

- `Cannot read properties of undefined (reading '<field>')`: A step of the path does not exist, for example `$json.body.customer.phone.number` when `phone` is missing. Use optional chaining (`?.`) or `$ifEmpty`.

In JSONata: `$$json.body.email`. Or the field names directly: JSONata reads the input as its context (body.email).

## `$binary`

Variable · `object` · Reserved · Source: `Sommatic AI expression engine`

> **Reserved.** The engine does not fill it yet: today it is always `{}`. Do not base logic on it.

```javascript
$binary
```

Meant for the files attached to the current item, one key per file with `{ data, mimeType, fileName }`. The engine does not fill it yet: it is always an empty object. Nodes that handle files today return them inside their output, so read files from `$json` (for example the attachments of an email trigger) or from the node that produced them with `$('…')`.

### Examples

```javascript
{{ $binary }}
```

Result (object):

```json
{}
```

```javascript
{{ Object.keys($binary).length }}
```

Result (number):

```json
0
```

In JSONata: `$$binary`

## `$itemIndex`

Variable · `number` · Reserved · Source: `Sommatic AI expression engine`

> **Reserved.** Each node execution handles one item: today it is always `0`.

```javascript
$itemIndex
```

Meant to be the zero-based position of the item being processed when a node handles a batch. A node handles one item per execution, so it is always `0`. To work with the position of an element inside a list, use the index that `map`, `forEach` or `findIndex` give you, or iterate with `flow.split`.

### Examples

```javascript
{{ $itemIndex }}
```

Result (number):

```json
0
```

The position of each element of a list.

```javascript
{{ $json.body.items.map((item, index) => index + ': ' + item.sku) }}
```

Result (list):

```json
[
  "0: A-100",
  "1: B-200",
  "2: C-300"
]
```

In JSONata: `$$itemIndex`

## `$runIndex`

Variable · `number` · Reserved · Source: `Sommatic AI expression engine`

> **Reserved.** The attempt number is not passed to expressions: today it is always `0`, also on retries.

```javascript
$runIndex
```

Meant to count the attempts of the current node (0 on the first, 1 on the first retry…). The engine does not pass the attempt number to expressions: it is `0` on every attempt, retries included. Retry behaviour is configured per node with its `execution` settings (`retryOnFail`, `maxTries`).

### Examples

```javascript
{{ $runIndex }}
```

Result (number):

```json
0
```

In JSONata: `$$runIndex`

## Example context

The examples run over this data: the input of the current node (`$json`), the nodes that already ran (`$(…)`), the ids of the run and the current node. The clock is fixed at `2026-11-26T14:30:00.000Z` and the server zone is UTC, so `$now` and `$today` give the same values on every page.

```json
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "ana.perez@example.com",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  },
  "nodes": {
    "Webhook Receiver": "= $json",
    "Normalize input": {
      "correlation_id": "c-7f3a",
      "channel": "web"
    },
    "Classify": {
      "label": "billing",
      "confidence": 0.92
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-xxxx",
    "$flow_instance_id": "fi-xxxx",
    "$flow_definition_id": "fd-xxxx",
    "$flow_version_id": "fv-xxxx",
    "$flow_slug": "order-intake"
  },
  "node": {
    "node_id": "node-notify",
    "label": "Notify customer"
  }
}
```

The examples of a chained workflow run over a second context: a workflow started by `workflow.chain`, whose `workflow.trigger` node is labelled `Chain Entry Point`.

```json
{
  "$json": {
    "order_id": "ord_1042",
    "customer_email": "ana.perez@example.com",
    "amount": 46,
    "chain_context": {
      "caller_flow_definition_id": "fd-caller-xxxx",
      "caller_flow_instance_id": "fi-caller-xxxx",
      "caller_flow_slug": "order-intake",
      "caller_node_id": "node-chain-billing",
      "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
      "root_flow_instance_result_id": "fir-root-xxxx"
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-hop-xxxx",
    "$flow_instance_id": "fi-hop-xxxx",
    "$flow_definition_id": "fd-billing-xxxx",
    "$flow_version_id": "fv-billing-xxxx",
    "$flow_slug": "billing-review",
    "$input": {
      "data": {
        "order_id": "ord_1042",
        "customer_email": "ana.perez@example.com",
        "amount": 46
      },
      "chain_context": {
        "caller_flow_definition_id": "fd-caller-xxxx",
        "caller_flow_instance_id": "fi-caller-xxxx",
        "caller_flow_slug": "order-intake",
        "caller_node_id": "node-chain-billing",
        "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
        "root_flow_instance_result_id": "fir-root-xxxx"
      }
    }
  },
  "node": {
    "node_id": "node-create-task",
    "label": "Create review task"
  }
}
```

Examples run against the orchestrator at commit 31e874b.
