---
id: flow--build-array
title: "Build array"
summary: "Collects single records arriving on `Input` into one collection record and sends it to `Output` when the batch they belong to completes (e.g. one file read, one Sql query execution), or, for records without a batch, when the buffer is full or after an idle timeout. Use it to batch records for bulk inserts, bulk API calls or to rebuild a list after a ForEach."
audience: user
keywords: "input, output, outputproperty, batchsize, autoflushtimeout, batchscope"
---
# Build array

Collects single records arriving on `Input` into one collection record and sends it to `Output` when the batch they belong to completes (e.g. one file read, one Sql query execution), or, for records without a batch, when the buffer is full or after an idle timeout. Use it to batch records for bulk inserts, bulk API calls or to rebuild a list after a ForEach.

## Pins

| Pin | Kind | Types | Description |
|---|---|---|---|
| Input | input | any | Single records to collect. Connect it before reconfiguring, the input type determines the generated output type. |
| Output | output | generated `<flow namespace>.<InputTypeName>Collection` | A record with one list property `Items` holding the collected input records. |

## Configuration

| Field | Type | Default | Description |
|---|---|---|---|
| `OutputProperty` | string | `Items` | Required. Name of the list property on the output type. Changing it regenerates the output type (see Notes: keep `Items`). |
| `BatchSize` | integer | `0` | Maximum records per output record. `0` = unlimited: in a batch the whole batch, without a batch until the timeout. |
| `AutoFlushTimeout` | integer (ms, 50-10000) | `500` | Records without a batch only: idle time after the last added record after which the collected records are flushed. |
| `BatchScope` | batch scope selector | empty | Which batch is collected into one array. Empty = the closest batch producer upstream. A component id of a batch producer upstream = the batches of that producer. `None` = ignore batches. |

## Behaviour

- Reconfigure (changing `OutputProperty` or pressing its reconfigure button) creates the flow type `<InputTypeName>Collection` in the flow's namespace with a list property `Items` whose item type is the input type, and sets it as the type of `Output`. Without this step the component has no output type and silently drops every record.
- Records in a batch (see `BatchScope`) are collected per batch. When the whole batch has been processed the array is sent with the metadata of the last record; it stays in the batch, so batch consumers behind Build array (Write file, Bulk insert) include it before they commit. When the batch failed the records are discarded. With `BatchSize` > 0 a full array is sent right away and the rest at the end. No timeout, no record positions involved, concurrent batches never mix. If the selected producer is not upstream of a record, the record fails.
- Records without a batch (or `BatchScope` `None`) are added to an internal buffer. A flush (one record on `Output`, buffer cleared) happens when:
  - `BatchSize` > 0 and the buffer holds `BatchSize` records;
  - no record was added for longer than `AutoFlushTimeout` ms. The idle check starts with the first record and runs every `AutoFlushTimeout` ms, so the actual delay is between one and two timeouts.
- The output record carries the metadata of the record that triggered the flush (for the timeout flush: of the last received record).
- Stream boundaries come from batches; records without a batch have none.

## Notes

- The generated type always names the list property `Items`, whatever `OutputProperty` says, and on start the plugin checks that the output type has a property named `OutputProperty`. Any other value makes the flow fail to start ("There is no ... defined on the output type"). Keep `OutputProperty` = `Items`.
- Without a batch the array is closed only by `BatchSize` or the timeout: records of several sources that arrive within one timeout end up in the same array. Put a batch producer upstream for exact boundaries.
- Without a batch the buffer is shared by all callers of the component: records from concurrent requests end up in the same array.
- The generated item type is declared in the flow's namespace with the input type's short name; it works best when the input type is a flow type.

## Example

```json
{ "OutputProperty": "Items", "BatchSize": 100, "AutoFlushTimeout": 1000 }
```

Database reader → Data mapper → **Build array** → Http client (bulk POST)
