# Expression API reference

> Every variable and helper an expression can use, with its signature, arguments, return value, errors and examples run against the engine Sommatic AI runs.

Source: https://docs.sommatic.ai/en/expressions/reference/

Everything an expression inside `{{ }}` can read or call. Each example on these pages was run against the expression engine of the orchestrator, as it is deployed, over one [example context](#example-context); the result shown is what the engine returned.

## Previous Nodes

- [Previous Nodes](https://docs.sommatic.ai/en/expressions/reference/previous-nodes.md): The expression API of every node: the paths of its output that later nodes read with $("Label").item.json, as the editor suggests them and as the worker returns them.

## Input Data

- [`$json`](https://docs.sommatic.ai/en/expressions/reference/input-data.md#json) → `object`: The input of the current node.
- [`$binary`](https://docs.sommatic.ai/en/expressions/reference/input-data.md#binary) → `object`: Binary data (files) attached to the current item. Reserved: always {}.
- [`$itemIndex`](https://docs.sommatic.ai/en/expressions/reference/input-data.md#item-index) → `number`: Index of the current item in a batch. Reserved: always 0.
- [`$runIndex`](https://docs.sommatic.ai/en/expressions/reference/input-data.md#run-index) → `number`: Index of the current attempt. Reserved: always 0.

## Input Access

- [`$input.item`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-item) → `{ json, binary }`: The current input item: { json, binary }.
- [`$input.all()`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-all) → `list`: Every input item, as a list. One item per execution.
- [`$input.first()`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-first) → `{ json, binary }`: The first input item (the current one).
- [`$input.last()`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-last) → `{ json, binary }`: The last input item (the current one).
- [`$input.params`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-params) → `object`: Configuration of the previous node. Reserved: always {}.
- [`$input.context`](https://docs.sommatic.ai/en/expressions/reference/input-access.md#input-context) → `object`: Context passed by the previous node. Reserved: always {}.

## Node Reference

- [`$(label)`](https://docs.sommatic.ai/en/expressions/reference/node-reference.md#node-accessor) → `NodeAccessor`: The output of an earlier node, found by its label.
- [`$prevNode`](https://docs.sommatic.ai/en/expressions/reference/node-reference.md#prev-node) → `object`: Metadata of the previous node. Reserved: always Start.
- [`$('Chain Entry Point').item.json`](https://docs.sommatic.ai/en/expressions/reference/node-reference.md#chain-entry) → `{ …data, chain_context }`: What a workflow started by workflow.chain receives: the data and the chain context.

## Execution Context

- [`$execution`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#execution) → `object`: Ids of the current run.
- [`$workflow`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#workflow) → `object`: Slug and version of the workflow that runs.
- [`$node`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#node) → `object`: Id and label of the current node.
- [`$env`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#env) → `object`: Variables of the environment. Reserved: always {}.
- [`$vars`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#vars) → `object`: Workflow variables. Reserved: always {}.
- [`$nodeVersion`](https://docs.sommatic.ai/en/expressions/reference/execution-context.md#node-version) → `number`: Version of the current node operator. Reserved: always 1.

## Date & Time

- [`$now`](https://docs.sommatic.ai/en/expressions/reference/date-time.md#now) → `DateTime`: The moment the node runs, as a Luxon DateTime.
- [`$today`](https://docs.sommatic.ai/en/expressions/reference/date-time.md#today) → `DateTime`: The start of the current day, as a Luxon DateTime.

## Generators

- [`$uuid`](https://docs.sommatic.ai/en/expressions/reference/generators.md#uuid) → `string`: A new UUID v4 on every read.
- [`$randomId({ length, prefix })`](https://docs.sommatic.ai/en/expressions/reference/generators.md#random-id) → `string`: A random id with a prefix.

## Encoders

- [`$base64Encode(value)`](https://docs.sommatic.ai/en/expressions/reference/encoders.md#base64-encode) → `string`: URL-safe Base64 of a text or of a JSON value.
- [`$base64Decode(text)`](https://docs.sommatic.ai/en/expressions/reference/encoders.md#base64-decode) → `string`: The text encoded in a Base64 string.
- [`$toQueryString(object)`](https://docs.sommatic.ai/en/expressions/reference/encoders.md#to-query-string) → `string`: A URL query string that starts with ?.

## Validators

- [`$isEmpty(value)`](https://docs.sommatic.ai/en/expressions/reference/validators.md#is-empty) → `boolean`: true when the value has no own keys.

## Helpers

- [`$ifEmpty(value, fallback)`](https://docs.sommatic.ai/en/expressions/reference/helpers.md#if-empty) → `any`: value, or fallback when value is empty.
- [`$slugify(text)`](https://docs.sommatic.ai/en/expressions/reference/helpers.md#slugify) → `string`: A lowercase, hyphenated slug.
- [`$jmespath(data, query)`](https://docs.sommatic.ai/en/expressions/reference/helpers.md#jmespath) → `any`: The result of a JMESPath query over any value.
- [`_`](https://docs.sommatic.ai/en/expressions/reference/helpers.md#lodash) → `lodash`: lodash: about 300 functions for lists, objects and text.

## JavaScript Globals

- [JavaScript Globals](https://docs.sommatic.ai/en/expressions/reference/javascript-globals.md): Math, JSON, text, numbers, lists, objects, dates, regular expressions, Map and Set, Intl, and what does not exist.

## Libraries

- [lodash](https://docs.sommatic.ai/en/expressions/lodash.md): Every lodash function, as `_`.
- [Luxon dates](https://docs.sommatic.ai/en/expressions/luxon.md): Every DateTime method of `$now` and `$today`.
- [JMESPath](https://docs.sommatic.ai/en/expressions/jmespath.md): The query language of `$jmespath`.
- [JSONata functions](https://docs.sommatic.ai/en/expressions/jsonata-functions.md): The functions of JSONata fields.

## What does not exist

Names a developer often expects, from other tools or older docs, that the engine does not provide. A name that does not exist throws `… is not defined`.

- `$node["X"].json`: `$node` is only the current node. Read other nodes with `$('X').item.json`.
- `$items()`: `$input.all()` or `$('X').all()`.
- `$parameter`: The node's own configuration is not exposed to its expressions.
- `$config`: Service configuration is never exposed.
- `DateTime`: Not a global name. Use `$now.constructor`.
- `Several items per node`: Each node execution handles one item. Iterate with `flow.split` and `flow.join`, or with `map` inside one expression.

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