# Execution Context

> Ids of the current run, the workflow and the node being executed, and the environment.

Source: https://docs.sommatic.ai/en/expressions/reference/execution-context/

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

## `$execution`

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

```javascript
$execution
```

The identity of the run. Write `$execution.id` in messages, tasks and logs so anyone can trace a case back to its run. When the run was started by [`workflow.chain`](https://docs.sommatic.ai/en/nodes/workflow.chain/), `id` is the id of the root run, so every workflow of the chain shares it; `run_flow_instance_result_id` keeps the id of this specific run.

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$execution.id` | `string` | The principal id of the run: the result id of the root run of the chain, or of this run when there is no chain. |
| `$execution.flow_instance_result_id` | `string \| null` | The principal result id (the same value as `id`). |
| `$execution.root_flow_instance_result_id` | `string \| null` | The result id of the root run of a chain. |
| `$execution.run_flow_instance_result_id` | `string \| null` | The result id of this run, also inside a chain. |
| `$execution.flow_instance_id` | `string \| null` | The id of the flow instance. |
| `$execution.flow_definition_id` | `string \| null` | The id of the workflow definition. |
| `$execution.flow_version_id` | `string \| null` | The id of the published version that runs. |
| `$execution.flow_slug` | `string \| null` | The workflow slug. |
| `$execution.mode` (Reserved) | `string` | Reserved: meant to tell a test run from a production one; today always `'manual'`. |
| `$execution.resumeUrl` (Reserved) | `undefined` | Reserved: meant for resuming a paused run; today always `undefined`. |
| `$execution.customData` (Reserved) | `object` | Reserved: always `{}`. |

### Examples

```javascript
Case received. Reference: {{ $execution.id }}
```

Result (string):

```json
"Case received. Reference: fir-xxxx"
```

```javascript
{{ ({ run: $execution.id, workflow: $execution.flow_slug, version: $execution.flow_version_id }) }}
```

Result (object):

```json
{
  "run": "fir-xxxx",
  "workflow": "order-intake",
  "version": "fv-xxxx"
}
```

Reserved member: the same value in every run.

```javascript
{{ $execution.mode }}
```

Result (string):

```json
"manual"
```

### Notes

- A field the run does not have is `null`. The ids are opaque text: compare them, never parse them.
- A node's own `execution` configuration field (its retry settings) has nothing to do with `$execution`.

In JSONata: `$$execution.id`

## `$workflow`

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

```javascript
$workflow
```

The workflow being executed. Use `slug` and `version`; `id`, `name` and `active` are reserved and hold fixed values today (for the id of the definition, read `$execution.flow_definition_id`).

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$workflow.slug` | `string \| null` | The workflow slug. |
| `$workflow.version` | `string \| null` | Identifies the version that runs (today, the id of the published version). Treat it as an opaque value, not as a number. |
| `$workflow.id` (Reserved) | `string` | Reserved: today always `'unknown'`. Use `$execution.flow_definition_id`. |
| `$workflow.name` (Reserved) | `string` | Reserved: today always `'Untitled'`. |
| `$workflow.active` (Reserved) | `boolean` | Reserved: today always `false`. |

### Examples

```javascript
{{ $workflow.slug + '@' + $workflow.version }}
```

Result (string):

```json
"order-intake@fv-xxxx"
```

The whole object, reserved members included.

```javascript
{{ $workflow }}
```

Result (object):

```json
{
  "id": "unknown",
  "name": "Untitled",
  "active": false,
  "slug": "order-intake",
  "version": "fv-xxxx"
}
```

In JSONata: `$$workflow.slug`

## `$node`

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

```javascript
$node
```

Metadata of the node being executed. It is not a way to read other nodes: for that, use [`$('Node label')`](#node-accessor).

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$node.id` | `string` | The node's `node_id`. |
| `$node.label` | `string \| null` | The node's label, as shown on the canvas. |
| `$node.name` | `string \| null` | The same value as `label`. |

### Examples

```javascript
Created by {{ $node.label }} in {{ $workflow.slug }}
```

Result (string):

```json
"Created by Notify customer in order-intake"
```

```javascript
{{ $node.id }}
```

Result (string):

```json
"node-notify"
```

In JSONata: `$$node.label`

## `$env`

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

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

```javascript
$env
```

Meant for variables declared for the environment a workflow runs in. The engine does not fill it yet: it is always an empty object, and it never exposes the service's own environment. Pass environment-specific values through the trigger input or through a [Git Sync environment](https://docs.sommatic.ai/en/git-sync/environments-and-tokens/), and secrets through a credential bound to the node.

### Examples

```javascript
{{ $env }}
```

Result (object):

```json
{}
```

A default keeps the expression working while it is empty.

```javascript
{{ $ifEmpty($env.API_BASE_URL, 'https://api.example.com') }}
```

Result (string):

```json
"https://api.example.com"
```

In JSONata: `$$env`

## `$vars`

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

> **Reserved.** Not filled: today it is always `{}`.

```javascript
$vars
```

Reserved for workflow variables. It is always an empty object. Never put secrets in variables: bind a credential to the node instead.

### Examples

```javascript
{{ $vars }}
```

Result (object):

```json
{}
```

In JSONata: `$$vars`

## `$nodeVersion`

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

> **Reserved.** Today always `1`.

```javascript
$nodeVersion
```

Meant to be the version of the operator that runs the current node. It is always `1`, whatever the node's `operator_version`. The operator version is part of the node definition in the workflow file.

### Examples

```javascript
{{ $nodeVersion }}
```

Result (number):

```json
1
```

In JSONata: `$$nodeVersion`

## 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.
