> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/connector-configuration/utils/controls/each.md).

# Each

### Overview

The **Each Component** iterates over a list and outputs a new message for each item.

The recommended way to build a loop in Appmixer is **Each** with **Sequential** turned on, the steps you want to run for every item, and the [Continue Each](/connector-configuration/utils/controls/continueeach.md) component at the end:

```
Each (Sequential) ──item──▶ step ▶ step ▶ Continue Each
      │
      └──done──▶ steps after the loop (use the collected result)
```

**Each** sends one item, waits until **Continue Each** confirms it, and only then sends the next one. The items are processed one at a time and in order, and every item can add values to the loop's **Result**. Once all items are done, the `done` port emits the result, one entry per item. You don't need Storage or **Join Each** to collect it.

Running items in parallel (without **Sequential**) is still possible, see [Other Options (Advanced)](#other-options-advanced).

### Building a Loop

1. **Provide a List**
   * Set **Field** (`list`) to an array, or to a string with a valid JSON array.
2. **Turn On Sequential**
   * Leave **Item Timeout** at its default (300 seconds) unless one item can take longer.
3. **Add the Steps for One Item**
   * Connect them to the `item` port. Use the `value` variable of the `item` port for the current item.
4. **End the Loop with Continue Each**
   * Connect [Continue Each](/connector-configuration/utils/controls/continueeach.md) after the last step that has to finish before the next item starts.
   * Map its **Correlation ID** and **Index** to the `correlationId` and `index` variables of the `item` port.
5. **Collect Results (Optional)**
   * In **Continue Each**, add a row to **Add to Result** for every value you want to keep, for example `id` → *ID of the created record*.
6. **Continue After the Loop**
   * Connect the steps that should run once all items are done to the `done` port. The collected values are in `result`.

If an item is not confirmed within **Item Timeout** (a step failed, or a Condition filtered the item out before **Continue Each**), the loop moves on to the next item instead of stopping. That item's entry in `result` is `null`.

### Usage

#### Input Parameters

| Parameter     | Type               | Description                                                                                                                                                                 |
| ------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `list`        | `array` / `string` | The list to iterate over. If a string is provided, it must be a valid JSON array.                                                                                           |
| `sequential`  | `boolean`          | Send the next item only after the previous one has been confirmed by **Continue Each**. Off by default. Turn it on for the recommended loop.                                |
| `itemTimeout` | `number`           | Sequential mode only. How long (in seconds) to wait for **Continue Each** to confirm an item before the loop moves on to the next one. Default 300, minimum 60.             |
| `delay`       | `number`           | Optional. Delay between items in milliseconds (at most 60000). In sequential mode it is an extra pause before each next item, for example to stay within an API rate limit. |

#### Input Ports

| Port | Description                        |
| ---- | ---------------------------------- |
| `in` | Receives the list to iterate over. |

#### Output Ports

| Port   | Description                                                                                                   |
| ------ | ------------------------------------------------------------------------------------------------------------- |
| `item` | Emits each item from the list with additional metadata.                                                       |
| `done` | Fires after all items have been processed, with the total count, the correlation ID and the collected result. |

#### Output Data for `item` Port

| Field           | Description                                |
| --------------- | ------------------------------------------ |
| `index`         | The index of the current item in the list. |
| `value`         | The value of the current item.             |
| `count`         | Total number of items in the list.         |
| `correlationId` | Unique identifier of this loop run.        |

#### Output Data for `done` Port

| Field           | Description                                                                                                                                                                                                                                       |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count`         | The total number of processed items.                                                                                                                                                                                                              |
| `correlationId` | Unique identifier of this loop run.                                                                                                                                                                                                               |
| `result`        | One entry per item, in item order: an object with the fields that **Continue Each** added for that item, `{}` when it added none, or `null` for an item that was skipped after **Item Timeout**. Always an empty list when **Sequential** is off. |

Example of `result` for a loop that created a record for every item, where the second item timed out:

```json
[
  { "id": "1001", "status": "created" },
  null,
  { "id": "1003", "status": "created" }
]
```

### Other Options (Advanced)

* **Parallel processing (Sequential off)**: all items are sent right away. This is faster, but when the steps after **Each** take a varying amount of time, faster items overtake slower ones, so the items leave the loop in a different order. `result` on the `done` port is empty, and `done` fires as soon as all items have been *sent*, not processed. To collect the processed items, use [Join Each](/connector-configuration/utils/controls/joineach.md) with the `correlationId` and `count` of **Each**.
* **Delay without Sequential**: spaces the items out in time, but does not keep them in order.

### Notes

* **Supports JSON Parsing**: If `list` is a string, it will attempt to parse it as JSON.
* **State Persistence**: Keeps track of progress and resumes processing if interrupted.
* **Nested Loops**: Every sequential **Each** needs its own **Continue Each**, mapped to its own `correlationId` and `index`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appmixer.com/connector-configuration/utils/controls/each.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
