Product Create API 文档

商品-创建

接口信息

  • 接口地址: {your-site-url}/api/skill/product/create
  • 基础 URL: {your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/apimanager666
  • 请求方式: POST
  • Content-Type: application/json
  • 说明: 此接口用于新增商品

认证

请求头中需要携带 skill-access-token

Header
skill-access-token {your-skill-access-token} (请替换为你自己的 token)

请求参数 (Body - JSON)

顶层字段

字段 类型 必填 说明
product Object ✅ 必填 产品主体数据
productattr_info Array 选填 产品属性信息
images Array ✅ 必填 产品图片
videos Array 选填 产品视频列表
addition_group_id string/int 选填 附加分组 ID
variantremark_id string/int 选填 变体备注 ID
groupbuy_id string/int 选填 团购 ID
collection_ids Array[int] 选填 产品对应的专辑 ID 数组(多对多关系)
label_ids Array 选填 角标 ID 数组
options Array 选填 产品规格定义。单规格为空,多规格必填
variants Array ✅ 必填 产品变体(规格)。单规格产品数组只有一个子项
glasses Object 选填 眼镜类商品属性
mergeimages Array 选填 合并图片列表
tags Array 选填 商品 tag 数组

product 字段详表

字段 类型 必填 说明
spu string 选填 产品 SPU
title string ✅ 必填 产品标题
sub_title string 选填 产品副标题
body_html string ✅ 必填 产品描述(HTML)
handle string 选填 商品 URL handle。不填写则用 title 自动生成
status int 选填 产品状态。1 上架,2 下架。默认上架
type int ✅ 必填 产品规格类型。1 单规格,2 多规格
vendor string 选填 产品厂家/品牌名称
virtual_sales_count int 选填 产品虚拟销量
is_tax int 选填 是否收税。1 收税,2 不收税
payafteruse int 选填 先用后付。1 先用后付商品,2 普通商品
variant_need_image int 选填 规格是否需要图片。1 需要,2 不需要。默认 1
variant_show_image int 选填 前台商城规格显示方式。1 显示文字,2 显示图片,3 使用插件默认配置
variant_need_note int 选填 变体是否需要备注。1 需要,2 不需要
inventory_police int 选填 是否跟踪库存。1 跟踪,2 不跟踪。默认 1
inventory_police_type int 选填 库存策略。1 库存为0允许购买,2 库存为0不允许购买,3 库存为0自动下架。默认 1
meta_is_edit int 选填 SEO 信息是否独立编辑。1 非独立编辑,2 独立编辑
meta_title string 选填 SEO 标题(meta title)
meta_keywords string 选填 SEO 关键字(meta keywords)
meta_description string 选填 SEO 描述(meta description)
feed_title string 选填 Feed 自定义 title
feed_description string 选填 Feed 自定义 description
translate_type int 选填 翻译类型。1 强制翻译,2 只翻译多语言为空的部分,3 不翻译
source_type int/string 选填 source 类型。1 代表 1688
template_type string 选填 模版装修的 template key
google_product_category int 选填 Google 商品分类 ID
google_product_type_id string 选填 Google 产品类型
description_json Object 选填 JSON 描述内容(模板装修数据)
description_json_status int 选填 描述是否使用 JSON 字段。1 开启,2 关闭
params_json Array 选填 参数 JSON 内容
params_json_status int 选填 参数是否使用 JSON。1 开启,2 关闭
short_description_json Array[Object] 选填 简短描述(JSON 格式数组,支持多语言)。每项含 text(默认文本)和 lang_params(多语言翻译对象)
collection_ids Array[int] 选填 产品对应的专辑 ID 数组
label_ids Array 选填 角标 ID 数组
short_description_json 结构说明

每项格式:

{
    "text": "默认文本",
    "lang_params": {
        "text": {
            "cn": "中文翻译"
        }
    }
}

productattr_info 字段详表

字段 类型 必填 说明
attr_id int ✅ 必填 属性 ID
item_ids Array[int] ✅ 必填 属性值 ID 数组
id string 选填 记录 ID(新增时为空字符串)

images 字段详表

新增时不需要传 id,系统会自动生成。

字段 类型 必填 说明
src string ✅ 必填 产品图片路径
alt string 选填 图片 alt 文本
position int ✅ 必填 图片排序位置,从 1 开始依次递增。标识为 1 的将作为主图
width int 选填 图片宽度(像素)
height int 选填 图片高度(像素)
ratio string 选填 宽高比
key float 选填 前端唯一标识 key

videos 字段详表

新增时不需要传 id

字段 类型 必填 说明
src string ✅ 必填 视频 URL 路径
alt string 选填 视频 alt 文本
position int ✅ 必填 排序位置
key float 选填 前端唯一标识 key

options 字段详表

单规格产品为空,多规格产品必填。新增时不需要传 id

字段 类型 必填 说明
name string ✅ 必填 规格名称(如 "Color"、"Size")
position int ✅ 必填 规格排序,值只能为 123 中的一个,且每个 option 的 position 不可重复
items Array[string] ✅ 必填 规格子项数组(如 ["White", "Black"]

variants 字段详表

单规格产品数组只有一个子项。新增时不需要传 id

字段 类型 必填 说明
price float ✅ 必填 售卖价格
qty int ✅ 必填 变体库存,默认 0
weight string ✅ 必填 变体重量
weight_unit string ✅ 必填 重量单位。可选值:g(克)、kg(千克)、lb(磅)、oz(盎司)
option1 string 选填 规格值 1。其值必须存在于 optionsposition=1 所在行的 items 数组中
option2 string 选填 规格值 2。其值必须存在于 optionsposition=2 所在行的 items 数组中
option3 string 选填 规格值 3。其值必须存在于 optionsposition=3 所在行的 items 数组中
cost_price float 选填 成本价格
compare_at_price float 选填 划线价格
wholesale_price Array[Object] 选填 批发价格。每项含 qty(批发个数,int)和 price(批发价格,float)
sku string ✅/选填 产品 SKU。根据配置项决定必填唯一、选填唯一或选填非唯一
barcode string 选填 条形码
image string 选填 变体图片路径。注意:此图片必须存在于 images 数组中,否则无法保存
note string 选填 变体备注
buy_min_count int 选填 最小起购数量
customervip Array[Object] 选填 VIP 会员价格。每项含 customervip_id(VIP等级ID,int)和 price(VIP价格,float)
images Array 选填 变体图片列表

tags 字段详表

新增时传 id: ""(空字符串)。

字段 类型 必填 说明
id string 选填 Tag ID(新增时传空字符串 "",已有 tag 传实际 ID)
title string 选填 Tag 标题

glasses 字段详表

字段 类型 必填 说明
button_type int 选填 按钮类型
distance_min string 选填 最小距离
distance_max string 选填 最大距离
sex Object 选填 适用性别。含 value(默认值)和 language(多语言对象,如 {"cn": "性别"}
lens_type Object 选填 镜片类型。含 value(默认值)和 language(多语言对象,如 {"cn": "类型"}
material Object 选填 材质。含 value(默认值)和 language(多语言对象,如 {"cn": "材料"}

mergeimages 字段详表

字段 类型 必填 说明
src string ✅ 必填 图片路径
position int ✅ 必填 图片位置排序
alt string 选填 图片 alt 文字
width int 选填 图片宽度(像素)
height int 选填 图片高度(像素)
ratio string 选填 宽高比

请求示例

cURL

curl --location --request POST '{your-site-url}/api/skill/product/create' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "product": {
        "spu": "3232323",
        "title": "Morden Lighting Nordic Fabric Shade Black White Floor Lamp",
        "sub_title": "Morden Lighting Nordic Fabric Shade Black White Floor Lamp subtitle",
        "body_html": "...(HTML 模板装修内容,详见下方 body_html 说明)...",
        "status": 1,
        "is_tax": 1,
        "payafteruse": 1,
        "virtual_sales_count": "33",
        "type": 2,
        "vendor": "Lighting Made",
        "variant_need_image": "1",
        "variant_show_image": 3,
        "inventory_police": "1",
        "inventory_police_type": 1,
        "meta_is_edit": "2",
        "meta_title": "Morden Lighting Nordic Fabric Shade Black White Floor Lamp",
        "meta_keywords": "Morden Lighting",
        "meta_description": "Morden Lighting Nordic Fabric Shade Black White Floor Lamp, ...",
        "feed_description": "google feed description",
        "feed_title": "google feed title",
        "handle": "morden-lighting-nordic-fabric-shade-black-white-floor-lamp",
        "translate_type": 3,
        "google_product_category": 111,
        "google_product_type_id": "light",
        "description_json": "(Object,模板装修 JSON 数据,包含 collage-tabs 和 brand-list 两个 section,详见下方说明)",
        "description_json_status": 1,
        "params_json": [],
        "params_json_status": 2,
        "short_description_json": [
            {
                "text": "Morden Lighting Nordic Fabric Shade Black White Floor Lamp",
                "lang_params": {
                    "text": {
                        "cn": "摩登照明北欧布艺灯罩黑白落地灯"
                    }
                }
            },
            {
                "text": "Nordic Fabric Shade Black White Floor Lamp",
                "lang_params": {
                    "text": {
                        "cn": "北欧风格黑白布艺灯罩落地灯"
                    }
                }
            }
        ],
        "template_type": "product",
        "variant_need_note": "1"
    },
    "productattr_info": [],
    "images": [
        {
            "src": "/product/15/image/2026/04/28/3fb5620f4acf97bdf9d056a6220b87e0.jpg",
            "position": 1,
            "alt": "",
            "width": 600,
            "height": 600,
            "ratio": "1.00"
        },
        {
            "src": "/product/15/image/2026/04/28/f6d04b41c743455948ed5dfea357a53e.jpg",
            "position": 2,
            "alt": "",
            "width": 600,
            "height": 600,
            "ratio": "1.00"
        },
        {
            "src": "/product/15/image/2026/04/28/858278fe4f6d493ece46810169a4df21.jpg",
            "position": 3,
            "alt": "",
            "width": 600,
            "height": 600,
            "ratio": "1.00"
        }
    ],
    "videos": [
        {
            "src": "https://cloud.video.taobao.com/play/u/2206786293671/p/1/e/6/t/1/453995116363.mp4",
            "position": 1,
            "alt": ""
        }
    ],
    "addition_group_id": 73,
    "variantremark_id": 9,
    "groupbuy_id": 12,
    "collection_ids": [342, 343],
    "label_ids": [],
    "options": [
        {
            "name": "Color",
            "position": 1,
            "items": ["grey", "white"]
        },
        {
            "name": "Size",
            "position": 2,
            "items": ["L", "M"]
        }
    ],
    "variants": [
        {
            "price": "59.99",
            "compare_at_price": "69.99",
            "cost_price": "29.99",
            "sku": "3232323-grey-L-1010805",
            "barcode": "1111",
            "image": "/product/15/image/2026/04/28/3fb5620f4acf97bdf9d056a6220b87e0.jpg",
            "qty": 8999,
            "option1": "grey",
            "option2": "L",
            "option3": "",
            "weight": "11",
            "weight_unit": "kg",
            "note": "grey l",
            "buy_min_count": 1,
            "wholesale_price": [
                {"qty": 2, "price": "45.88"},
                {"qty": 5, "price": "41.88"}
            ],
            "customervip": [
                {"customervip_id": 11, "price": 44},
                {"customervip_id": 10, "price": 45},
                {"customervip_id": 8, "price": 46},
                {"customervip_id": 7, "price": 47}
            ]
        },
        {
            "price": "59.99",
            "compare_at_price": "69.99",
            "cost_price": "29.99",
            "sku": "3232323-grey-M-1010806",
            "barcode": "2222",
            "image": "/product/15/image/2026/04/28/3fb5620f4acf97bdf9d056a6220b87e0.jpg",
            "qty": 8999,
            "option1": "grey",
            "option2": "M",
            "option3": "",
            "weight": "11",
            "weight_unit": "kg",
            "note": "grey m",
            "buy_min_count": 1,
            "wholesale_price": [
                {"qty": 2, "price": "45.88"},
                {"qty": 5, "price": "41.88"}
            ],
            "customervip": [
                {"customervip_id": 11, "price": 44},
                {"customervip_id": 10, "price": 45},
                {"customervip_id": 8, "price": 46},
                {"customervip_id": 7, "price": 47}
            ]
        },
        {
            "price": "59.99",
            "compare_at_price": "69.99",
            "cost_price": "29.99",
            "sku": "3232323-white-L-1010807",
            "barcode": "3333",
            "image": "/product/15/image/2026/04/28/858278fe4f6d493ece46810169a4df21.jpg",
            "qty": 8999,
            "option1": "white",
            "option2": "L",
            "option3": "",
            "weight": "11",
            "weight_unit": "kg",
            "note": "white l",
            "buy_min_count": 1,
            "wholesale_price": [
                {"qty": 2, "price": "45.88"},
                {"qty": 5, "price": "41.88"}
            ],
            "customervip": [
                {"customervip_id": 11, "price": 44},
                {"customervip_id": 10, "price": 45},
                {"customervip_id": 8, "price": 46},
                {"customervip_id": 7, "price": 47}
            ]
        },
        {
            "price": "59.99",
            "compare_at_price": "69.99",
            "cost_price": "29.99",
            "sku": "3232323-white-M-1010808",
            "barcode": "4444",
            "image": "/product/15/image/2026/04/28/858278fe4f6d493ece46810169a4df21.jpg",
            "qty": 8999,
            "option1": "white",
            "option2": "M",
            "option3": "",
            "weight": "11",
            "weight_unit": "kg",
            "note": "white m",
            "buy_min_count": 1,
            "wholesale_price": [
                {"qty": 2, "price": "45.88"},
                {"qty": 5, "price": "41.88"}
            ],
            "customervip": [
                {"customervip_id": 11, "price": 44},
                {"customervip_id": 10, "price": 45},
                {"customervip_id": 8, "price": 46},
                {"customervip_id": 7, "price": 47}
            ]
        }
    ],
    "glasses": {
        "button_type": 1,
        "distance_min": "11",
        "distance_max": "99",
        "sex": {
            "value": "sex",
            "language": {"cn": "性别"}
        },
        "lens_type": {
            "value": "style",
            "language": {"cn": "类型"}
        },
        "material": {
            "value": "type",
            "language": {"cn": "材料"}
        }
    },
    "mergeimages": [],
    "tags": [
        {"title": "white", "id": ""},
        {"title": "black", "id": ""}
    ]
}'

返回结果

code200 表示调用成功;code 不为 200 表示调用失败。

成功响应

{
    "code": 200,
    "data": {
        "product_id": 4693
    },
    "message": "success"
}

返回字段说明

字段 类型 说明
code Number 状态码,200 表示成功
message String 执行结果的文字描述
data.product_id int 创建成功后返回的新产品 ID

错误响应

{
    "code": 100701001,
    "message": "error message"
}

错误码说明

错误码 说明
100701003 商品id为空
100701001 商品保存报错
其他错误码 商品保存报错

/api/skill/product/update/api/skill/product/create 参数结构几乎一致,主要区别:

区别点 Create(新增) Update(更新)
接口地址 /api/skill/product/create /api/skill/product/update
product.id 不需要传 ✅ 必填
images[].id 不需要传 选填(更新已有图片时传入)
videos[].id 不需要传 选填(更新已有视频时传入)
options[].id 不需要传 选填(更新已有规格时传入)
variants[].id 不需要传 选填(更新已有变体时传入)
tags[].id 传空字符串 ""(新建 tag) 传已有 tag 的 ID

注意事项

  1. body_html 为商品详情页的 HTML 模板装修内容,与 description_json 对应
  2. 变体的 image 字段必须已存在于 images 数组中,否则无法保存
  3. images[].position 必须从 1 开始连续递增,position=1 的图片为主图
  4. options[].position 只能为 123,且每个 option 的 position 不可重复
  5. variants 中的 option1/2/3 值必须与对应 positionoptions[].items 中的值匹配
  6. wholesale_price 为变体的批发价格数组,每个元素包含 qty(起批数量)和 price(批发单价)
  7. weight_unit 支持 gkglboz 四种单位
  8. description_json 为模板装修数据(Object),非数组;description_json_status1 时才生效
  9. short_description_json 每项包含 text(默认文本)和 lang_params.text.{语言}(多语言翻译)
  10. 新增时所有实体的 id 字段均不需要传(或传空),系统会自动生成
Copyright © fecify.com 2025 all right reserved,powered by Gitbook该文件修订时间: 2026-05-07 18:34:55

results matching ""

    No results matching ""