On this page
Sommatic Docs
Open portal

Generators

New random identifiers.

View as Markdown
Open in

Each example was run against the deployed expression engine over the example context at the end of the page.

$uuid

$uuid

A random UUID version 4, 36 characters in the 8-4-4-4-12 hexadecimal layout. It is a property, not a function: write $uuid, not $uuid(). Every read produces a new value, even twice in the same expression.

Examples

{{ $uuid }}
Result string Random: a new value on every run
"d5d1221a-b9bc-4f05-ac90-de73b5841ca9"
{{ 'msg-' + $uuid }}
Result string Random: a new value on every run
"msg-c2e2e36c-61ac-46c7-8d1c-952afe5e313e"

Errors

Message Cause and fix
$uuid is not a function It was called as $uuid(). Remove the parentheses.

Notes

  • When several nodes need the same id, generate it once (for example in a data.transform) and read it from that node with $('…').

In JSONata $$uuid

$randomId

$randomId({ length, prefix })

Returns prefix followed by length random hexadecimal characters (0-9, a-f). Use it for human-friendly references; for a standard identifier use $uuid.

Parameters

options object required
Always pass an object, even an empty one: $randomId() without it fails.
options.length number optional default 15
How many random characters (up to 512).
options.prefix string optional default 'id-'
Text placed before them.

Returns

string prefix + length hexadecimal characters.

Examples

{{ $randomId({ length: 8, prefix: 'ord-' }) }}
Result string Random: a new value on every run
"ord-70fb73b5"
{{ $randomId({}) }}
Result string Random: a new value on every run
"id-fe83456fd23b165"

Without the options object it fails.

{{ $randomId() }}
Throws
Cannot destructure property 'length' of 'undefined' as it is undefined.

Errors

Message Cause and fix
Cannot destructure property 'length' of 'undefined' as it is undefined. It was called without the options object. Pass {} at least.

In JSONata $$randomId({ "length": 8, "prefix": "ord-" })

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.

Input of the current node 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 that already ran (label → output) JSON
{
  "Webhook Receiver": "= $json",
  "Normalize input": {
    "correlation_id": "c-7f3a",
    "channel": "web"
  },
  "Classify": {
    "label": "billing",
    "confidence": 0.92
  }
}
Run and current node JSON
{
  "$execution": {
    "id": "fir-xxxx",
    "flow_instance_id": "fi-xxxx",
    "flow_definition_id": "fd-xxxx",
    "flow_version_id": "fv-xxxx",
    "flow_slug": "order-intake"
  },
  "$node": {
    "id": "node-notify",
    "label": "Notify customer"
  }
}

Examples run against the orchestrator at commit 31e874b

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs