**版本：202201**

# 创建集合关联

**POST** `/openapi/2022-01/collects`

将商品关联到指定集合。

## 请求

**application/json**

**请求体 | 示例**

**请求体**

- `collect` object

  - `collection_id` string

    Collection's ID, for example: `0097cfc8-63c3-45ed-ab9f-6f2231b700k9`
  - `product_id` string

    Product's ID, for example: `0097cfc8-63c3-45ed-ab9f-6f2231b700k9`

```json
{
  "collect": {
    "collection_id": "string",
    "product_id": "string"
  }
}
```

## 响应

**200 | 422**

200

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `collect` object

  - `id` string

    **示例：** `c0bcd1a9-8a42-4b8d-b2eb-b8a11b742da6`
  - `collection_id` string

    **示例：** `a60fe556-43ad-4e07-9125-507ac1bf71f7`
  - `product_id` string

    **示例：** `ea8f38ba-a152-4c64-a12c-50ea77ac4245`
  - `position` integer

    **默认值：** `0`

    **示例：** `2`
  - `created_at` string

    **示例：** `2024-04-16T11:34:32Z`
  - `updated_at` string

    **示例：** `2024-04-16T11:34:32Z`

```json
{
  "collect": {
    "id": "c0bcd1a9-8a42-4b8d-b2eb-b8a11b742da6",
    "collection_id": "a60fe556-43ad-4e07-9125-507ac1bf71f7",
    "product_id": "ea8f38ba-a152-4c64-a12c-50ea77ac4245",
    "position": 2,
    "created_at": "2024-04-16T11:34:32Z",
    "updated_at": "2024-04-16T11:34:32Z"
  }
}
```

```json
{
    "collect": {
        "id": "c0bcd1a9-8a42-4b8d-b2eb-b8a11b742da6",
        "collection_id": "a60fe556-43ad-4e07-9125-507ac1bf71f7",
        "product_id": "ea8f38ba-a152-4c64-a12c-50ea77ac4245",
        "position": 2,
        "created_at": "2024-04-16T11:34:32Z",
        "updated_at": "2024-04-16T11:34:32Z"
    }
}
```

422

**application/json**

**数据结构 | 示例 | Result**

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "ProductId is required"
  ]
}
```

```json
{
  "errors": [
    "ProductId is required"
  ]
}
```
