变更已有字段,破坏性操作未确认时只返回预览

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,不能改名

labelstring

rename_label 时的新显示名

choicestring

add_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"
    }
  ]
}