> 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. It allows processing list elements individually, enabling sequential execution of subsequent actions.

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

#### 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, providing the total count and correlation ID. |

#### 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 for tracking batch processing. |

#### Output Data for `done` Port

| Field           | Description                                     |
| --------------- | ----------------------------------------------- |
| `count`         | The total number of processed items.            |
| `correlationId` | Unique identifier for tracking batch execution. |

### Instructions

1. **Provide a List**
   * Ensure the input `list` is an array or a valid JSON string representing an array.
2. **Processing Items**
   * Each item in the list is sent separately to the `item` port.
   * The `done` port is triggered after all items are processed.
3. **Handling Index and Correlation ID**
   * Each item is assigned an `index` and a `correlationId` to track processing.

### 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.
* **Efficient for Iteration**: Useful for batch processing workflows requiring individual handling of list elements.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
