# Add struct field

Add a struct-array field with its nested field definitions.

SDK: `@zilliz/milvus2-sdk-node@3.0.10` · Tested with Milvus 3.0.6

Canonical documentation: https://milvus-io.github.io/milvus-sdk-node/rest-api/schema/struct-fields/add/

## Section links

- [cURL command](https://milvus-io.github.io/milvus-sdk-node/rest-api/schema/struct-fields/add/#curl-command)
- [Default request](https://milvus-io.github.io/milvus-sdk-node/rest-api/schema/struct-fields/add/#default-request)
- [Sample response](https://milvus-io.github.io/milvus-sdk-node/rest-api/schema/struct-fields/add/#sample-response)
- [Request fields](https://milvus-io.github.io/milvus-sdk-node/rest-api/schema/struct-fields/add/#request-fields)

`POST /v2/vectordb/collections/struct_fields/add`

Replace `https://your-cluster.example.com` with your Milvus endpoint. Set `MILVUS_TOKEN` for authentication or omit the Authorization header on an unauthenticated cluster.

## cURL command

```bash
curl --request POST --url 'https://your-cluster.example.com/v2/vectordb/collections/struct_fields/add' \
  --header 'Content-Type: application/json' \
  --header "Authorization: Bearer ${MILVUS_TOKEN}" \
  --data-raw '{
  "dbName": "default",
  "collectionName": "books",
  "schema": {
    "fieldName": "editions",
    "dataType": "Array",
    "elementDataType": "Struct",
    "typeParams": {
      "max_capacity": "16"
    },
    "nullable": true,
    "fields": [
      {
        "fieldName": "year",
        "dataType": "Array",
        "elementDataType": "Int32",
        "elementTypeParams": {
          "max_capacity": "16"
        }
      }
    ]
  }
}'
```

## Default request

```json
{
  "dbName": "default",
  "collectionName": "books",
  "schema": {
    "fieldName": "editions",
    "dataType": "Array",
    "elementDataType": "Struct",
    "typeParams": {
      "max_capacity": "16"
    },
    "nullable": true,
    "fields": [
      {
        "fieldName": "year",
        "dataType": "Array",
        "elementDataType": "Int32",
        "elementTypeParams": {
          "max_capacity": "16"
        }
      }
    ]
  }
}
```

## Sample response

```json
{
  "code": 0,
  "data": {}
}
```

## Request fields

- `dbName` string
  Database name. Operations on collections use default when omitted.
- `collectionName` string (required)
  Name of the collection.
- `schema` object (required)
  Schema definition with field names, data types and type parameters.

See [`HttpClient.addCollectionStructField`](https://milvus-io.github.io/milvus-sdk-node/api-reference/http-client/#addcollectionstructfield) for the Node.js SDK method.
