**版本：202201**

# 创建商品

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

根据提供的信息创建一个新商品。

## 请求

**application/json**

**请求体 | 示例**

**请求体**

- `product` object (required)

  - `title` string (required)

    Product's title
  - `brief` string

    Product's briefing description
  - `description` string

    Product's description
  - `published` boolean

    Whether it is published or not
  - `requires_shipping` boolean

    Whether it is required to shipping
  - `taxable` boolean

    Whether it is taxable
  - `tags` string

    Tags, separated by comma, for example: `tag1,tag2`
  - `vendor` string

    Vendor's name
  - `vendor_url` string

    Vendor's URL
  - `note` string
  - `seo_title` string

    SEO title
  - `seo_description` string

    SEO description
  - `seo_keywords` string

    SEO keywords, separated by comma, for example: `key1,key2`
  - `handle` string

    Product's handle
  - `has_only_default_variant` boolean (required)

    Whether it is a single variant

    **默认值：** `true`
  - `inventory_tracking` boolean

    Whether to tracking inventory
  - `inventory_policy` string

    Inventory policy: `continue`, `deny`, `auto_unpublished`, required while `inventory_tracking` is true
  - `need_variant_image` boolean

    Whether variant image is needed. It's required if has_only_default_variant is false
  - `spu` string

    Product's SPU
  - `fake_sales` int32

    Product's fake sales
  - `display_fake_sales` boolean

    Whether to display fake sales
  - `options` object[]

    *   Array [

    - `name` string (required)

      Option's name, for example: "color","size".
    - `values` string[] (required)

      Option's values, for example: ["red", "black"],["small", "large"]

      **默认值：** `[]`
    *   ]
  - `images` object[]

    *   Array [

    - `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
    *   ]
  - `variants` object[]

    *   Array [

    - `option1` string

      Option 1
    - `option2` string

      Option 2
    - `option3` string

      Option 3
    - `image` object

      Variant's images, e.g.: `{"src":"//cn.cdn.shoplazza.com/c8bf5695d347092d7a010f00182581f7.jpeg"}`

      - `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
    - `compare_at_price` string

      Compare at price ( original price )
    - `price` string (required)

      Price, set it to "0.00" if you want to leave the price empty.
    - `sku` string

      SKU
    - `barcode` string

      The barcode of the variant
    - `note` string
    - `inventory_quantity` int32

      Inventory quantity
    - `weight` string
    - `weight_unit` string

      Unit of weight, possible value are: `kg`, `g`, `lb`, `oz`
    - `cost_price` string

      Cost price
    - `wholesale_price` object[]

      *   Array [

      - `price` string
      - `min_quantity` int32

        Mini Order Quantity
      *   ]
    *   ]
  - `unique_token` string

    Unique_token is a unique string identifier generated by your app, will be used for idempotency verification, for example: `e6cc4df1-d4f5-4ad4-a019-2e0f3ddd6e63`
  - `mixed_wholesale` boolean

    Whether mixed wholesale is supported

```json
{
  "product": {
    "title": "string",
    "brief": "string",
    "description": "string",
    "published": true,
    "requires_shipping": true,
    "taxable": true,
    "tags": "string",
    "vendor": "string",
    "vendor_url": "string",
    "note": "string",
    "seo_title": "string",
    "seo_description": "string",
    "seo_keywords": "string",
    "handle": "string",
    "has_only_default_variant": true,
    "inventory_tracking": true,
    "inventory_policy": "string",
    "need_variant_image": true,
    "spu": "string",
    "fake_sales": 0,
    "display_fake_sales": true,
    "options": [
      {
        "name": "string",
        "values": [
          "string"
        ]
      }
    ],
    "images": [
      {
        "src": "string",
        "width": 0,
        "height": 0,
        "alt": "string"
      }
    ],
    "variants": [
      {
        "option1": "string",
        "option2": "string",
        "option3": "string",
        "image": {
          "src": "string",
          "width": 0,
          "height": 0,
          "alt": "string"
        },
        "compare_at_price": "string",
        "price": "string",
        "sku": "string",
        "barcode": "string",
        "note": "string",
        "inventory_quantity": 0,
        "weight": "string",
        "weight_unit": "string",
        "cost_price": "string",
        "wholesale_price": [
          {
            "price": "string",
            "min_quantity": 0
          }
        ]
      }
    ],
    "unique_token": "string",
    "mixed_wholesale": true
  }
}
```

## 响应

**200 | 422 | 425 | 500**

200

**application/json**

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

**数据结构**

- `product` object

  - `id` string

    **示例：** `9fb9f3c6-2300-42c1-8593-d9008d7cfc09`
  - `title` string

    **示例：** `Stylish Shirt`
  - `brief` string

    **示例：** `A stylish shirt.`
  - `description` string

    **示例：**
  - `published` boolean

    **默认值：** `true`

    **示例：** `true`
  - `requires_shipping` boolean

    **默认值：** `true`

    **示例：** `true`
  - `taxable` boolean

    **默认值：** `true`

    **示例：** `true`
  - `tags` string

    **示例：** `shirt,stylish,cotton`
  - `vendor` string

    **示例：** `Awesome Vendor`
  - `vendor_url` string

    **示例：** `https://awesomevendor.com`
  - `inventory_quantity` integer

    **默认值：** `0`

    **示例：** `300`
  - `published_at` string

    **示例：** `2024-12-03T19:02:30Z`
  - `created_at` string

    **示例：** `2024-12-03T19:02:30Z`
  - `updated_at` string

    **示例：** `2024-12-03T19:02:30Z`
  - `note` string

    **示例：** `Special promotion item.`
  - `seo_title` string

    **示例：** `Buy Stylish Shirt Online`
  - `seo_description` string

    **示例：** `Premium cotton`
  - `seo_keywords` string

    **示例：** `shirt, cotton, stylish`
  - `handle` string

    **示例：** `stylish-shirt-zbxf`
  - `has_only_default_variant` boolean

    **默认值：** `true`

    **示例：** `false`
  - `inventory_tracking` boolean

    **默认值：** `true`

    **示例：** `true`
  - `inventory_policy` string

    **示例：** `continue`
  - `need_variant_image` boolean

    **默认值：** `true`

    **示例：** `false`
  - `spu` string

    **示例：** `SS1234`
  - `fake_sales` integer

    **默认值：** `0`

    **示例：** `50`
  - `display_fake_sales` boolean

    **默认值：** `true`

    **示例：** `true`
  - `mixed_wholesale` boolean

    **默认值：** `true`

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

    - `src` string

      **示例：** `//img.fantaskycdn.com/loading.png`
    - `width` integer

      **默认值：** `0`

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

      **默认值：** `0`

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

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

      **示例：**
  - `images` object[]

    *   Array [

    - `id` string

      **示例：** `15333433-a0d5-44c9-941b-2c59ea07683e`
    - `product_id` string

      **示例：** `9fb9f3c6-2300-42c1-8593-d9008d7cfc09`
    - `position` integer

      **默认值：** `0`

      **示例：** `1`
    - `src` string

      **示例：** `//img.fantaskycdn.com/loading.png`
    - `width` integer

      **默认值：** `0`

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

      **默认值：** `0`

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

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

      **示例：** `2024-12-03T19:02:30Z`
    - `updated_at` string

      **示例：** `2024-12-03T19:02:30Z`
    *   ]
  - `options` object[]

    *   Array [

    - `id` string

      **示例：** `8e40555e-a152-45fc-9587-fe85280701c5`
    - `product_id` string

      **示例：** `9fb9f3c6-2300-42c1-8593-d9008d7cfc09`
    - `position` integer

      **默认值：** `0`

      **示例：** `1`
    - `name` string

      **示例：** `Size`
    - `values` string[]
    *   ]
  - `variants` object[]

    *   Array [

    - `id` string

      **示例：** `d7c7f9ba-f824-46b6-94af-1c2d1befaf27`
    - `product_id` string

      **示例：** `9fb9f3c6-2300-42c1-8593-d9008d7cfc09`
    - `image_id` string

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

      **示例：** `2024-12-03T19:02:30Z`
    - `updated_at` string

      **示例：** `2024-12-03T19:02:30Z`
    - `title` string

      **示例：** `Small-Red`
    - `option1` string

      **示例：** `Small`
    - `option2` string

      **示例：** `Red`
    - `option3` string

      **示例：**
    - `image`
    - `position` integer

      **默认值：** `0`

      **示例：** `1`
    - `compare_at_price` string

      **示例：** `29.99`
    - `price` string

      **示例：** `19.99`
    - `sku` string

      **示例：** `SS1234-RD-S`
    - `barcode` string

      **示例：** `123456789012`
    - `note` string

      **示例：** `Limited`
    - `inventory_quantity` integer

      **默认值：** `0`

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

      **示例：** `0.50`
    - `weight_unit` string

      **示例：** `kg`
    - `cost_price` string

      **示例：** `12.99`
    - `wholesale_price` object[]

      *   Array [

      - `price` string

        **示例：** `19.99`
      - `min_quantity` integer

        **默认值：** `0`

        **示例：** `1`
      *   ]
    - `extend`
    *   ]
  - `category`

```json
{
  "product": {
    "id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
    "title": "Stylish Shirt",
    "brief": "A stylish shirt.",
    "description": "",
    "published": true,
    "requires_shipping": true,
    "taxable": true,
    "tags": "shirt,stylish,cotton",
    "vendor": "Awesome Vendor",
    "vendor_url": "https://awesomevendor.com",
    "inventory_quantity": 300,
    "published_at": "2024-12-03T19:02:30Z",
    "created_at": "2024-12-03T19:02:30Z",
    "updated_at": "2024-12-03T19:02:30Z",
    "note": "Special promotion item.",
    "seo_title": "Buy Stylish Shirt Online",
    "seo_description": "Premium cotton",
    "seo_keywords": "shirt, cotton, stylish",
    "handle": "stylish-shirt-zbxf",
    "has_only_default_variant": false,
    "inventory_tracking": true,
    "inventory_policy": "continue",
    "need_variant_image": false,
    "spu": "SS1234",
    "fake_sales": 50,
    "display_fake_sales": true,
    "mixed_wholesale": true,
    "image": {
      "src": "//img.fantaskycdn.com/loading.png",
      "width": 100,
      "height": 100,
      "path": "loading.png",
      "alt": ""
    },
    "images": [
      {
        "id": "15333433-a0d5-44c9-941b-2c59ea07683e",
        "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
        "position": 1,
        "src": "//img.fantaskycdn.com/loading.png",
        "width": 100,
        "height": 100,
        "alt": "",
        "created_at": "2024-12-03T19:02:30Z",
        "updated_at": "2024-12-03T19:02:30Z"
      }
    ],
    "options": [
      {
        "id": "8e40555e-a152-45fc-9587-fe85280701c5",
        "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
        "position": 1,
        "name": "Size",
        "values": [
          "Small"
        ]
      }
    ],
    "variants": [
      {
        "id": "d7c7f9ba-f824-46b6-94af-1c2d1befaf27",
        "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
        "image_id": "",
        "created_at": "2024-12-03T19:02:30Z",
        "updated_at": "2024-12-03T19:02:30Z",
        "title": "Small-Red",
        "option1": "Small",
        "option2": "Red",
        "option3": "",
        "image": {},
        "position": 1,
        "compare_at_price": "29.99",
        "price": "19.99",
        "sku": "SS1234-RD-S",
        "barcode": "123456789012",
        "note": "Limited",
        "inventory_quantity": 100,
        "weight": "0.50",
        "weight_unit": "kg",
        "cost_price": "12.99",
        "wholesale_price": [
          {
            "price": "19.99",
            "min_quantity": 1
          }
        ],
        "extend": {}
      }
    ],
    "category": {}
  }
}
```

```json
{
    "product": {
        "id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
        "title": "Stylish Shirt",
        "brief": "A stylish shirt.",
        "description": "",
        "published": true,
        "requires_shipping": true,
        "taxable": true,
        "tags": "shirt,stylish,cotton",
        "vendor": "Awesome Vendor",
        "vendor_url": "https://awesomevendor.com",
        "inventory_quantity": 300,
        "published_at": "2024-12-03T19:02:30Z",
        "created_at": "2024-12-03T19:02:30Z",
        "updated_at": "2024-12-03T19:02:30Z",
        "note": "Special promotion item.",
        "seo_title": "Buy Stylish Shirt Online",
        "seo_description": "Premium cotton",
        "seo_keywords": "shirt, cotton, stylish",
        "handle": "stylish-shirt-zbxf",
        "has_only_default_variant": false,
        "inventory_tracking": true,
        "inventory_policy": "continue",
        "need_variant_image": false,
        "spu": "SS1234",
        "fake_sales": 50,
        "display_fake_sales": true,
        "mixed_wholesale": true,
        "image": {
            "src": "//img.fantaskycdn.com/loading.png",
            "width": 100,
            "height": 100,
            "path": "loading.png",
            "alt": ""
        },
        "images": [
            {
                "id": "15333433-a0d5-44c9-941b-2c59ea07683e",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "position": 1,
                "src": "//img.fantaskycdn.com/loading.png",
                "width": 100,
                "height": 100,
                "alt": "",
                "created_at": "2024-12-03T19:02:30Z",
                "updated_at": "2024-12-03T19:02:30Z"
            },
            {
                "id": "a926bfff-03b4-4d00-bd85-cae50e7f4941",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "position": 2,
                "src": "//img.fantaskycdn.com/loading.png",
                "width": 100,
                "height": 100,
                "alt": "",
                "created_at": "2024-12-03T19:02:30Z",
                "updated_at": "2024-12-03T19:02:30Z"
            }
        ],
        "options": [
            {
                "id": "8e40555e-a152-45fc-9587-fe85280701c5",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "position": 1,
                "name": "Size",
                "values": [
                    "Small",
                    "Medium",
                    "Large",
                    "Extra Large"
                ]
            },
            {
                "id": "1e340474-6464-4d35-872c-75b751f6aa7f",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "position": 2,
                "name": "Color",
                "values": [
                    "Red",
                    "Blue",
                    "Black"
                ]
            }
        ],
        "variants": [
            {
                "id": "d7c7f9ba-f824-46b6-94af-1c2d1befaf27",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "image_id": "",
                "created_at": "2024-12-03T19:02:30Z",
                "updated_at": "2024-12-03T19:02:30Z",
                "title": "Small-Red",
                "option1": "Small",
                "option2": "Red",
                "option3": "",
                "image": null,
                "position": 1,
                "compare_at_price": "29.99",
                "price": "19.99",
                "sku": "SS1234-RD-S",
                "barcode": "123456789012",
                "note": "Limited",
                "inventory_quantity": 100,
                "weight": "0.50",
                "weight_unit": "kg",
                "cost_price": "12.99",
                "wholesale_price": [
                    {
                        "price": "19.99",
                        "min_quantity": 1
                    }
                ],
                "extend": null
            },
            {
                "id": "c7b74858-ad5a-4da3-9695-bdb936d3c057",
                "product_id": "9fb9f3c6-2300-42c1-8593-d9008d7cfc09",
                "image_id": "",
                "created_at": "2024-12-03T19:02:30Z",
                "updated_at": "2024-12-03T19:02:30Z",
                "title": "Medium-Blue",
                "option1": "Medium",
                "option2": "Blue",
                "option3": "",
                "image": null,
                "position": 2,
                "compare_at_price": "29.99",
                "price": "19.99",
                "sku": "SS1234-BL-M",
                "barcode": "123456789013",
                "note": "Best-selling",
                "inventory_quantity": 200,
                "weight": "0.60",
                "weight_unit": "kg",
                "cost_price": "13.99",
                "wholesale_price": [
                    {
                        "price": "19.99",
                        "min_quantity": 1
                    }
                ],
                "extend": null
            }
        ],
        "category": null
    }
}
```

422

**application/json**

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

**数据结构**

- `errors` string[]

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

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

425

**application/json**

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

**数据结构**

- `error` string[]

```json
{
  "error": [
    "Duplicate requests"
  ]
}
```

```json
{ "error": ["Duplicate requests"] }
```

500

**application/json**

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

**数据结构**

- `error` string[]

```json
{
  "error": [
    "failed to get unique token value"
  ]
}
```

```json
{ "error":[ "failed to get unique token value"] }
```
