变更已有字段,破坏性操作未确认时只返回预览
POST/api/v1/catalogs/{id}/fields/changes
| 认证 | 请求头 Authorization: Bearer <访问令牌>,访问令牌用设备码换取,不要向用户要密码、短信验证码或 API Key |
|---|---|
| 权限 | 商家,需要 field:write 才能新增或变更目录字段 |
路径参数
path
idstring必填目录 ID
路径示例
/api/v1/catalogs/cat_example/fields/changes请求体
application/json
一次只做一种 op
openum<string>必填变更种类
可选值: rename_labeladd_choiceremove_choicechange_typemake_optionalmake_requiredretire
keystring必填已有字段 key,不能改名
labelstringrename_label 时的新显示名
choicestringadd_choice 或 remove_choice 的选项
typeenum<string>change_type 的目标类型
可选值: textnumberbooleansingle-select
choicesstring[]改成 single-select 时必须带
confirmboolean破坏性变更写成 true 才会写入
请求示例
{
"op": "rename_label",
"key": "weight_g",
"label": "示例",
"choice": "string",
"type": "text",
"choices": [
"string"
],
"confirm": false
}响应
200
application/json
applied 为 true 才表示已写入。未确认时先读 breaking
appliedboolean必填true 才表示已写入,false 只是预览
breakingboolean未确认的破坏性变更时为 true。已写入时不返回
revisioninteger写入后的字段版本
affected_countinteger必填受影响商品数
fieldobject | null写入后的字段,预览时可能没有
affected[].product_idstring将被下架或已下架的商品 ID
affected[].reasonstring影响原因
响应示例
{
"applied": true,
"breaking": false,
"revision": 1,
"affected_count": 1,
"field": null,
"affected": [
{
"product_id": "prd_example",
"reason": "string"
}
]
}