# Array

## Specification

### spec

* Describes the data structure of array items.
* Parameters inside spec use the syntax of the regular parameters.

Available types:

<table><thead><tr><th width="138" valign="top">Type</th><th valign="top">Specification</th></tr></thead><tbody><tr><td valign="top"><strong>object</strong></td><td valign="top">The output is an array of primitive types. If the object contains a <code>name</code>, it will be ignored.</td></tr><tr><td valign="top"><strong>array</strong></td><td valign="top">The output is a complex array of Objects.</td></tr></tbody></table>

{% tabs %}
{% tab title="Object" %}

```json
{
	"name": "tags",
	"spec": {
		"type": "text",
		"label": "Tag"
	},
	"type": "array",
	"label": "Tags"
}
```

{% hint style="info" %}
When no spec is provided, the array behaves as a primitive array of strings. However, the preferred approach is setting the spec to `{"type": "text"}`.
{% endhint %}
{% endtab %}

{% tab title="Array" %}

```json
{
	"name": "contacts",
	"spec": [
		{
			"name": "email",
			"type": "email",
			"label": "Email"
		},
		{
			"name": "name",
			"type": "text",
			"label": "Name"
		}
	],
	"type": "array",
	"label": "Contacts"
```

{% endtab %}
{% endtabs %}

### validate

* Type: `Object`
* Collection of validation directives.

Available parameters:

<table><thead><tr><th width="149">Parameter</th><th width="95">Type</th><th>Specification</th></tr></thead><tbody><tr><td><strong>maxItems</strong></td><td>number</td><td>Specifies the maximum length that an array parameter can have.</td></tr><tr><td><strong>minItems</strong></td><td>number</td><td>Specifies the minimum length that an array parameter can have.</td></tr><tr><td><strong>enum</strong></td><td>array</td><td>Array of allowed values in the array.</td></tr></tbody></table>

{% tabs %}
{% tab title="maxItems example" %}

<div align="left"><figure><img src="/files/PsQcQaq0c2RrIw58cscY" alt="" width="416"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="minItems example" %}

<div align="left"><figure><img src="/files/EaMvDhEOLFd6uWKj0aNO" alt="" width="422"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Error message" %}

<div align="left"><figure><img src="/files/Ge6QVx3dEDEmYqVno2Rn" alt="" width="365"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "members",
		"type": "array",
		"label": "Members",
		"validate": {
			"minItems": 1,
			"maxItems": 4,
			"enum": [
				"member1",
				"member2",
				"member3",
				"member4"
			]
		}
	}
]
```

{% endtab %}
{% endtabs %}

### mode

* Type: `String`
* Allowed values are `edit` and `choose`.

When the array is `editable` , you can set the default state by using `mode`.

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/sL6iNaXZdaoZWsVCOIbF" alt="" width="542"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "choose",
		"type": "array",
		"label": "Choosable array",
		"mode": "choose"
	},
	{
		"name": "edit",
		"type": "array",
		"label": "Editable array",
		"mode": "edit"
	}
]
```

{% endtab %}
{% endtabs %}

### labels

Available parameters:

<table><thead><tr><th width="139.66668701171875" valign="top">Parameter</th><th width="95" valign="top">Type</th><th valign="top">Specification</th></tr></thead><tbody><tr><td valign="top"><strong>add</strong></td><td valign="top">string</td><td valign="top">Default: <code>Add item</code>. The text is displayed on the adding button.</td></tr></tbody></table>

## Examples

### Primitive array

The primitive array is an array of simple variables, like numbers or strings.

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/PbUMsdhTz3MeNPEzkVIN" alt="" width="542"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "tags",
		"spec": {
			"type": "text",
			"label": "Tag"
		},
		"type": "array",
		"label": "Tags"
	}
]
```

{% endtab %}

{% tab title="Output" %}

```json
["old", "new"]
```

{% endtab %}
{% endtabs %}

### Complex array

The complex array is an array of complex objects - collections.

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/I4UyuV4STAF7y30pPbNB" alt="" width="541"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "contacts",
		"spec": [
			{
				"name": "email",
				"type": "email",
				"label": "Email"
			},
			{
				"name": "name",
				"type": "text",
				"label": "Name"
			}
		],
		"type": "array",
		"label": "Contacts"
	}
]
```

{% endtab %}

{% tab title="Output" %}

```json
[
    {
        "name": "John Doe",
        "email": "john@doe.com"
    },
    {
        "name": "Foo Bar",
        "email": "foo@bar.baz"
    }
]
```

{% endtab %}
{% endtabs %}

### Complex array with labeled collections

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/qPhqPPkC6TzNWi788rJe" alt="" width="542"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "contacts",
		"spec": {
			"type": "collection",
			"label": "Contact",
			"spec": [
				{
					"name": "email",
					"type": "email",
					"label": "Email"
				},
				{
					"name": "name",
					"type": "text",
					"label": "Name"
				}
			]
	},
		"type": "array",
		"label": "Contacts"
	}
]
```

{% endtab %}

{% tab title="Output" %}

```json
[
    {
        "name": "John Doe",
        "email": "john@doe.com"
    },
    {
        "name": "Foo Bar",
        "email": "foo@bar.baz"
    }
]
```

{% endtab %}
{% endtabs %}

### Amount of items

Use the `validate` object to set `minItems` and `maxItems` to control the minimum and/or maximum amount of items in the array.

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/gAnQUsD0eNB8vndCXEsV" alt="" width="542"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "members",
		"type": "array",
		"label": "Members",
		"validate": {
			"minItems": 1,
			"maxItems": 4
		}
	}
]
```

{% endtab %}
{% endtabs %}

### Custom labels

Customize the button labels using the `labels` object.

{% tabs %}
{% tab title="Appearance" %}

<div align="left"><figure><img src="/files/jHSClrSceNx9FwZZEscq" alt="" width="539"><figcaption></figcaption></figure></div>
{% endtab %}

{% tab title="Source" %}

```json
[
	{
		"name": "labels",
		"type": "array",
		"label": "Customized array",
		"labels": {
			"add": "Add an item to my array"
		}
	}
]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://developers.make.com/custom-apps-documentation/block-elements/parameters/array.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
