# 创建捆绑包

创建捆绑包，即作为一个单位销售的一组商品。捆绑包可以包含虚拟物品、虚拟货币套餐、游戏Key以及其他捆绑包。有关更多信息，请参阅捆绑包部分。

提示content数组中的所有商品都必须提前在您的项目中创建。如果指定的SKU不存在，系统将返回错误。

Endpoint: POST /v2/project/{project_id}/admin/items/bundle
Version: 2.0.0
Security: basicAuth

## Path parameters:

  - `project_id` (integer, required)
    项目ID。您可以在发布商帐户的项目名称旁找到此参数；使用项目时，也可以在浏览器地址栏中找到此参数。URL格式如下：https://publisher.xsolla.com//projects/。
    Example: 44056

## Request fields (application/json):

  - `sku` (string, required)
    唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

  - `name` (object,null, required)
    包含商品本地化名称的对象。值接受以下两种格式之一：两个小写字母的语言代码（例如，en）或五个字符的语言代码（例如，en-US）。虽然两种格式都可作为输入接受，但响应会返回两个小写字母的语言代码。当为同一种语言提供了两种输入时（例如：en和en-US），将存储最后提供的值。您可以在[文档](/zh/doc/shop-builder/references/supported-languages/)中找到支持语言的完整列表。

  - `groups` (array)
    商品所属分组。

注：字符串值表示组external_id。

  - `attributes` (array)
    属性列表。

注意：每个商品最多可指定20个属性。任何超出限制的尝试都会导致错误。

  - `attributes.external_id` (string, required)
    唯一属性ID。 external_id只能包含大小写英文字母、数字、短横线和下划线。

  - `attributes.name` (object)
    包含属性本地化名称的对象。编码按照ISO 3166-1的规定。

  - `attributes.values` (array, required)
    注意：每个属性最多可创建6个值。任何超出限制的尝试都会导致错误。
    Example: [{"external_id":"strategy","value":{"en":"Strategy","de":"Strategie"}},{"external_id":"action","value":{"en":"Action","de":"Aktion"}}]

  - `attributes.values.external_id` (string, required)
    属性的唯一值ID。 external_id只能包含小写英文字母、数字、短横线和下划线。
    Example: "value_external_id"

  - `attributes.values.value` (object, required)
    包含值本地化名称的对象。编码按照ISO 3166-1的规定。

  - `description` (object,null, required)
    包含本地化商品描述的对象。值接受以下两种格式之一：两个小写字母的语言代码（例如，en）或五个字符的区域设置代码（例如，en-US）。虽然两种格式都可作为输入接受，但响应会返回两个小写字母的语言代码。当为同一种语言提供了两种输入时（例如：en和en-US），将存储最后提供的值。您可以在[文档](/zh/doc/shop-builder/references/supported-languages/)中找到支持语言的完整列表。

  - `long_description` (object,null)
    包含商品详细本地化描述的对象。值接受以下两种格式之一：两个小写字母的语言代码（例如，en）或五个字符的区域设置代码（例如，en-US）。虽然两种格式都可作为输入接受，但响应会返回两个小写字母的语言代码。当为同一种语言提供了两种输入时（例如：en和en-US），将存储最后提供的值。您可以在[文档](/zh/doc/shop-builder/references/supported-languages/)中找到支持语言的完整列表。

  - `image_url` (string,null)
    图片URL。为确保图片能在支付UI中正确显示并快速加载，请查看我们的图片和URL指南：支持的格式：WebP（推荐）、PNG、JPG。文件大小：≤50 KB（WebP）或≤150 KB（PNG和JPG）。图片尺寸：280 x 280 px。色彩空间：sRGB。协议：HTTPS，并对版本化URL使用长期缓存。

  - `prices` (array)
    以真实货币表示的价格。

  - `prices.amount` (string, required)
    商品价格。

  - `prices.currency` (string, required)
    商品价格币种。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准的三字母代码。

  - `prices.is_default` (boolean, required)
    如果未指定用户币种的价格，则使用默认价格生成商品目录。

  - `prices.is_enabled` (boolean, required)
    价格已启用。

  - `prices.country_iso` (string,null)
    适用此价格的国家/地区。符合[ISO 3166-1 alpha 2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)的两字母代码。
    Example: "US"

  - `vc_prices` (any)

  - `bundle_type` (string)
    捆绑包类型。使用standard创建包含商品的捆绑包，并指定捆绑包中所含商品的SKU。
使用partner_side_content创建一个空的捆绑包，并使用[Webhook](https://developers.xsolla.com/zh/webhooks/operation/personalized-partner-catalog/)在己侧添加商品。此类型仅用于[合作伙伴侧商品目录个性化](https://developers.xsolla.com/zh/doc/shop-builder/features/personalization/#guides_personalization_on_partner_side)。
    Enum: "standard", "partner_side_content"

  - `content` (array)
    捆绑包中包含的商品数组。每个条目用于指定商品SKU和数量。所有商品都必须提前在您的项目中创建。如果指定的SKU不存在，系统将返回错误。
    Example: [{"sku":"com.xsolla.kg_1","quantity":1}]

  - `content.sku` (string, required)
    要加入捆绑包的商品SKU。该商品必须提前在您的项目中创建。如果指定的SKU不存在，系统将返回错误。允许使用的字符：a–z、A–Z、0–9、句点（.）、连字符（-）、下划线（_）。
    Example: "com.xsolla.kg_1"

  - `content.quantity` (integer)
    捆绑包中所选商品的数量。
    Example: 1

  - `is_free` (boolean)
    该商品是否免费。

  - `is_paid_randomized_reward` (boolean)
    该商品是否为随机付费奖励，例如宝箱。

  - `is_enabled` (boolean)
    如果禁用，则无法找到和购买该商品。

  - `is_show_in_store` (boolean)
    商品可供购买。

  - `media_list` (any)

  - `order` (integer)
    捆绑包在列表中的排序优先级。

  - `regions` (array)

  - `regions.id` (integer)
    Example: 1

  - `limits` (object)
    商品限制数。

  - `limits.per_user` (any)
    单个用户的商品限制数。

  - `limits.per_item` (integer,null)
    全局商品限制数。

  - `limits.recurrent_schedule` (object,null)
    限制数刷新周期。

  - `limits.recurrent_schedule.per_user` (any)
    按指定小时间隔执行购买限制数重置。

  - `periods` (array,null)
    商品销售期。

  - `periods.date_from` (string)
    指定商品开始可购的日期。
    Example: "2020-08-11T10:00:00+03:00"

  - `periods.date_until` (string,null)
    指定商品停止可购的日期。可为null。
    Example: "2020-08-11T20:00:00+03:00"

  - `custom_attributes` (object)
    包含商品属性和值的JSON对象。属性可用于为商品添加更多信息，例如玩家使用该商品所需的等级。属性可丰富游戏的内部逻辑，并可通过专用GET方法和Webhook访问。

## Response 201 fields (application/json):

  - `sku` (string)
    唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

## Response 401 fields (application/json):

  - `statusCode` (integer)
    Example: 401

  - `errorCode` (integer)
    Example: 1020

  - `errorMessage` (string)
    Example: "[0401-1020]: Error in Authentication method occurred"

## Response 422 fields (application/json):

  - `statusCode` (integer)
    Example: 422

  - `errorCode` (integer)
    Example: 1102

  - `errorMessage` (string)
    Example: "[0401-1102]: Unprocessable Entity. The property `property_name` is required"

  - `transactionId` (string)
    Example: "x-x-x-x-transactionId-mock-x-x-x"

  - `errorMessageExtended` (array)


