**版本：202201**

# 创建商品专辑

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

在店铺中创建一个新的商品专辑，可设置专辑名称、描述、关联商品、SEO 信息及商品排序规则。

## 请求

**application/json**

**请求体 | 示例**

**请求体**

- `collection` object

  - `title` string (required)

    The title of the collection.
  - `handle` string

    The SEO link, the C-end album link is https://{subdomain}.myshoplaza.com/collections/{handle}.
  - `seo_title` string

    SEO title
  - `seo_description` string

    SEO description
  - `seo_keywords` string

    SEO Keywords, separated by comma, for example: `key1,key2`
  - `description` string

    The description of the collection, supports rich text.
  - `image` object

    The image for the collection. This image is added to the collection's page in the Shoplazza admin.

    - `src` string (required)

      Image's URL
    - `width` int32

      Image's width in px
    - `height` int32

      Image's height in px
    - `alt` string

      Image's alt
  - `sort_order` string

    Collection merchandise sorting rules:
    - default to `manual`
    - `sales-desc`: by total sales volume, hight to low
    - `published-desc`: by product published time, newest first
    - `real-sales-desc`:by product real sales, more to less
    - `inventory-quantity-asc`: by inventory quantity, less to more
    - `inventory-quantity-desc`: by inventory quantity, more to less
    - `views-desc`: by product page views, more to less
    - `add-to-cart-count-desc`: by add to card count, more to less
    - `updated-desc`: by product update time, newest first
    - `vendor-asc`: by supplier name A-Z
    - `vendor-desc`: by supplier name Z-A
    - `alpha-asc`: by product title A-Z
    - `alpha-desc`: by product title Z-A
    - `price-asc`: by price, low to high
    - `price-desc`: by price, high to low
    - `created-desc`: by creation time, newest first
    - `manual`: manually

    **默认值：** `manual`
  - `product_ids` string

    Product's IDs, separated by comma, for example: `0097cfc8-6ec3-40ed,40ed-ab9f-6f2231b7`

```json
{
  "collection": {
    "title": "string",
    "handle": "string",
    "seo_title": "string",
    "seo_description": "string",
    "seo_keywords": "string",
    "description": "string",
    "image": {
      "src": "string",
      "width": 0,
      "height": 0,
      "alt": "string"
    },
    "sort_order": "manual",
    "product_ids": "string"
  }
}
```

## 响应

**200 | 422**

200

**application/json**

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

**数据结构**

- `collection` object

  - `id` string

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

    **示例：** `Test-Collection`
  - `description` string

    **示例：** `Desc`
  - `handle` string

    **示例：** `test-collection`
  - `smart` boolean

    **默认值：** `true`

    **示例：** `false`
  - `image` object

    - `src` string

      **示例：** `//cdn.shoplazza.com/loading.png`
    - `width` integer

      **默认值：** `0`

      **示例：** `100`
    - `height` integer

      **默认值：** `0`

      **示例：** `100`
    - `alt` string

      **示例：**
    - `path` string

      **示例：** `loading.png`
  - `seo_title` string

    **示例：** `seo_title`
  - `seo_description` string

    **示例：** `Desc`
  - `seo_keywords` string

    **示例：** `test`
  - `sort_order` string

    **示例：** `title-asc`
  - `created_at` string

    **示例：** `2024-04-16T10:31:12Z`
  - `updated_at` string

    **示例：** `2024-04-16T10:31:12Z`

```json
{
  "collection": {
    "id": "a60fe556-43ad-4e07-9125-507ac1bf71f7",
    "title": "Test-Collection",
    "description": "Desc",
    "handle": "test-collection",
    "smart": false,
    "image": {
      "src": "//cdn.shoplazza.com/loading.png",
      "width": 100,
      "height": 100,
      "alt": "",
      "path": "loading.png"
    },
    "seo_title": "seo_title",
    "seo_description": "Desc",
    "seo_keywords": "test",
    "sort_order": "title-asc",
    "created_at": "2024-04-16T10:31:12Z",
    "updated_at": "2024-04-16T10:31:12Z"
  }
}
```

```json
{
    "collection": {
        "id": "a60fe556-43ad-4e07-9125-507ac1bf71f7",
        "title": "Test-Collection",
        "description": "Desc",
        "handle": "test-collection",
        "smart": false,
        "image": {
            "src": "//cdn.shoplazza.com/loading.png",
            "width": 100,
            "height": 100,
            "alt": "",
            "path": "loading.png"
        },
        "seo_title": "seo_title",
        "seo_description": "Desc",
        "seo_keywords": "test",
        "sort_order": "title-asc",
        "created_at": "2024-04-16T10:31:12Z",
        "updated_at": "2024-04-16T10:31:12Z"
    }
}
```

422

**application/json**

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

**数据结构**

- `errors` string[]

```json
{
  "errors": [
    "Title is taken."
  ]
}
```

```json
{
  "errors": [
    "Title is taken."
  ]
}
```
