On this page
Sommatic Docs
Open portal

Split In Batches

Splits an array into individual items or batches for parallel or iterative processing.

View as Markdown
Open in
Flow control Available flow.split Version 1.0.0 Execution: sync

Fans out an array: the engine runs the nodes connected to out once per item (or batch), then signals done with the item count.

This operator allows you to iterate over a list of items found in the input payload. For each item (or batch of items), it triggers the 'loop' output port. Once all items have been processed, it triggers the 'done' port.

Behavior:

  • Iteration: Emits a message for each item/batch in the array.
  • Context Preservation: Child executions inherit the parent context.
  • Batching: Can group items into batches (e.g., size 10) for efficiency.

Use Cases:

  • Processing a list of new users from a CSV.
  • Sending emails to a segment of subscribers.
  • Processing order line items individually.

How it works

  1. Resolves path. A {{ }} that returns an array or object ({{ $json.items }}) is used as is; plain text is evaluated as JSONata against the payload (data.items); an empty path uses the whole payload.
  2. Recovers an object with numeric keys ({ "0": {...}, "1": {...} }) as an array in key order; an empty object becomes [].
  3. Fails when the value is not an array.
  4. An empty array leaves directly through done with {}; nothing goes through out.
  5. Otherwise returns the array with meta.split and meta.batch_size. The engine queues every node connected to out once per item (batch_size 1) or per slice of batch_size items, each with that item or slice as payload.
  6. Then queues the nodes connected to done with { total_items }, the number of items.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-each-order",
  "label": "Each order",
  "operator_slug": "flow.split",
  "operator_version": "1.0.0",
  "config": {
    "path": "{{ $json.orders }}",
    "batch_size": 1
  }
}

Configuration

path string Optional Accepts expressions

JSONata path to the array in the input payload (e.g. `data.items`). If empty, the root payload is treated as the array.

batch_size integer Optional

Number of items to include in each emitted batch.

Default: 1

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

batch_size
With a value above 1 each out payload is an array slice, but done still reports the number of items, so a flow.join downstream never fires.

Output ports

out default

Once per item (or batch array when batch_size > 1). The payload is the item itself.

Data
{
  "order_id": "ord_1",
  "total": 10
}
done

After all items were queued. With an empty array the payload is {}.

Data
{
  "total_items": 3
}
error

The value at path is not an array, or JSONata failed.

Data
{
  "ok": false,
  "errors": [
    "Target at path 'data.items' is not an array. Got: object. Keys found: [id, name]"
  ],
  "port": "error"
}

In expressions

What a later node can read from this node's output with $("Split In Batches").item.json.<path> (write your node's label instead of Split In Batches). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Split In Batches").item.json.payloadarrayThe worker does not return it: reads as undefinedThe batch of items. —
$("Split In Batches").item.json.order_idstringNot suggested by the editor= "ord_1"—
$("Split In Batches").item.json.totalnumberNot suggested by the editor= 10—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Target at path '<path|root>' is not an array. Got: <type>. Keys found: [<keys>] error path points to an object, string or nothing. Check the path against the real payload.
<JSONata message> error Invalid JSONata in path; the message is in data.error.

Input contract

payload object Optional

Output contract

payload array<object> Optional

The batch of items.

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "flow.split",
  "name": "Split In Batches",
  "category": "flow",
  "version": "1.0.0",
  "description": "Splits an array into individual items or batches for parallel or iterative processing.\n\n  This operator allows you to iterate over a list of items found in the input payload. For each item (or batch of items), it triggers the 'loop' output port. Once all items have been processed, it triggers the 'done' port.\n\n  **Behavior:**\n  - **Iteration:** Emits a message for each item/batch in the array.\n  - **Context Preservation:** Child executions inherit the parent context.\n  - **Batching:** Can group items into batches (e.g., size 10) for efficiency.\n\n  **Use Cases:**\n  - Processing a list of new users from a CSV.\n  - Sending emails to a segment of subscribers.\n  - Processing order line items individually.",
  "capabilities": [
    "loop",
    "iteration",
    "array",
    "fan-out"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "title": "Array Input Path",
        "description": "JSONata path to the array in the input payload (e.g. `data.items`). If empty, the root payload is treated as the array.",
        "format": "expression"
      },
      "batch_size": {
        "type": "integer",
        "title": "Batch Size",
        "default": 1,
        "minimum": 1,
        "description": "Number of items to include in each emitted batch."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "description": "Payload containing the array to split.",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "description": "A single item or a batch of items from the source array.",
    "properties": {
      "payload": {
        "type": "array",
        "items": {
          "type": "object"
        },
        "description": "The batch of items."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Loop Item",
      "is_default": true,
      "description": "Emits for each item or batch in the array."
    },
    {
      "port_id": "done",
      "label": "Done",
      "description": "Activated when all items have been processed."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Activated if the input is not a valid array."
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "loop",
    "iterator",
    "fan-out",
    "batch"
  ],
  "is_stateful": true,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
Yes
Retries (retryOnFail)
No
Capabilities
loopiterationarrayfan-out
Tags
loopiteratorfan-outbatch

Notes and limits

  • Every node execution counts towards the engine limit of 100 steps per run; past it the run fails with Max step ceiling reached (100). Items are processed one after another in queue order, not in parallel.
  • done is queued right after the items reach their first node, so nodes on done can run before the item branches finish. Only flow.join waits for every item.
  • When the envelope has no data (or data is falsy), the engine stores the whole envelope as the node output: on error the next node receives { ok: false, errors: [...], port: "error" } as its payload.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

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