新增一个实际出售的组合,不会自动生成全部组合
POST/api/v1/catalogs/{id}/products/{product_id}/variants
| 认证 | 请求头 Authorization: Bearer <访问令牌>,访问令牌用设备码换取,不要向用户要密码、短信验证码或 API Key |
|---|---|
| 权限 | 商家,需要 product:write 才能修改商品、图片或店铺介绍 |
路径参数
path
idstring必填商品 ID
product_idstring必填商品 ID
路径示例
/api/v1/catalogs/prd_example/products/prd_example/variants请求体
application/json
不会自动生成全部组合
option_valuesobject必填已声明规格轴的取值
priceinteger必填整数分
stockinteger | null库存,null 表示不限
skustring | nullSKU
coverstring | null规格封面
请求示例
{
"option_values": {},
"price": 159900,
"stock": null,
"sku": null,
"cover": null
}响应
201
application/json
成功时 code 为 200,资源在 data
idstring必填商品 ID,以 prd_ 开头
catalog_idstring必填目录 ID
titlestring必填商品名称
statusenum<string>必填上架状态
可选值: onoff
coverstring | null必填封面地址
fieldsobject必填目录字段值
schema_revisioninteger必填字段定义版本
created_atstring必填创建时间,ISO-8601
updated_atstring必填更新时间,ISO-8601
deleted_atstring | null必填软删除时间,未删除时为 null
axes[].idstring必填规格轴 ID
axes[].keystring必填规格轴 key
axes[].labelstring必填规格轴名称
axes[].positioninteger必填规格轴顺序
variants[].idstring必填规格 ID
variants[].skustring | null必填SKU
variants[].option_valuesobject必填规格轴取值
variants[].priceinteger必填整数分
variants[].stockinteger | null必填库存,null 表示不限
variants[].statusenum<string>必填是否可售
可选值: onoff
variants[].coverstring | null必填规格封面
variants[].deletedboolean必填是否已软删除
响应示例
{
"id": "prd_example",
"catalog_id": "cat_example",
"title": "示例",
"status": "on",
"cover": "string",
"fields": {},
"schema_revision": 1,
"created_at": "2026-05-16T00:00:00.000Z",
"updated_at": "2026-05-16T00:00:00.000Z",
"deleted_at": "2026-05-16T00:00:00.000Z",
"axes": [
{
"id": "id_example",
"key": "weight_g",
"label": "示例",
"position": 1
}
],
"variants": [
{
"id": "var_example",
"sku": "string",
"option_values": {},
"price": 159900,
"stock": null,
"status": "on",
"cover": "string",
"deleted": true
}
]
}