POST
联系人

更新用户标签

POSThttps://api.xingyapi.com/api/contact/updateLabel

接口用途

用于更新用户标签。

请求说明

请求体使用 JSON 格式。设备相关接口通过 instance_guid 指定设备实例;其他字段说明见参数表。

返回说明

统一响应信封 {ok, code, message, request_id, data};code=0 表示成功,业务数据在 data 字段。

注意事项

- op=1(新增):label.id 与 label.createTime 传 0。

- op=2(删除):需完整提交 label 对象,其余参数无需单独更新;个人标签组不在删除范围。

- op=3(修改):仅可变更 label.name,其余 label 字段按原值完整提交。

- 个人标签不支持添加标签组,仅企业标签组支持该操作。

请求参数

字段类型说明
instance_guid必填string星云实例标识(inst_xxxx),标识本次操作的账号
userId必填integer用户唯一标识。
operItems必填array操作项列表;每个元素是一次标签操作(可批量),字段见下。
operItems[].op必填number操作类型:1=新增、2=删除、3=修改。
operItems[].opScenenumber操作场景:新增企业标签组时传 1;其余操作固定传 2。
operItems[].label必填object标签对象;子字段见下。其余属性(bDeleted/businessType/order/serviceGroupId 等)为标签固有属性,op=3 修改时按原值完整提交。
operItems[].label.idstring标签 ID;新增(op=1)时传 0。
operItems[].label.namestring标签名称;op=3 修改时仅此字段可变更。
operItems[].label.labelTypenumber标签类型:1=企业标签,2=个人标签。
operItems[].label.dataTypenumber数据类型:1=标签,2=标签组(与 labelType 组合:labelType=1+dataType=1 企业标签、1+2 企业标签组、2+1 个人标签、2+2 个人标签组)。
operItems[].label.labelGroupIdstring标签组 ID;新增标签组时传 0。
operItems[].label.createTimenumber创建时间(秒级时间戳);新增(op=1)时传 0。

请求示例

{
  "instance_guid": "inst_xxxxxxxx",
  "userId": 1688857990821417,
  "operItems": [
    {
      "op": 3,
      "opScene": 2,
      "label": {
        "id": "14073750445976458",
        "name": "测试",
        "dataType": 1,
        "bDeleted": 0,
        "labelGroupId": "14073751857989781",
        "createTime": 1787872137,
        "labelType": 2,
        "businessType": 0,
        "order": 0,
        "serviceGroupId": 0
      }
    },
    {
      "op": 3,
      "opScene": 2,
      "label": {
        "id": "14073750445976459",
        "name": "测试1",
        "dataType": 1,
        "bDeleted": 0,
        "labelGroupId": "14073751857989781",
        "createTime": 1787872147,
        "labelType": 2,
        "businessType": 0,
        "order": 0,
        "serviceGroupId": 0
      }
    }
  ]
}

响应字段

字段类型说明
businessIdnumber业务对象标识。
listarray标签相关数据列表。
list[].idnumber业务记录或消息内部标识。
list[].itemFlagnumber数据项状态或属性标识;具体含义以服务端协议为准。
list[].seqnumber数据序号或版本序列。
list[].createTimenumber创建时间戳。
list[].updateTimenumber更新时间戳。
list[].contentobject消息或业务内容对象;具体结构随内容类型而变化。
list[].createSeqnumber创建序列号,用于标识数据创建顺序或版本。
list[].DataTypenumber数据类型标识;具体枚举以服务端协议为准。

响应示例

{
  "ok": true,
  "code": 0,
  "message": "success",
  "request_id": "nb_xxxxxxxx",
  "data": {
    "businessId": 1,
    "list": [
      {
        "id": 7881303340347828,
        "itemFlag": 0,
        "seq": 11195327,
        "createTime": 1785303705,
        "updateTime": 1785382492,
        "content": {
          "userInfo": {
            "uin": 7881303340347828,
            "name": "星云API",
            "gender": 0,
            "iconUrl": "https://example.com/...",
            "corpId": 1970325134026788,
            "unionId": "oXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          "corpInfo": {},
          "flag": 2057,
          "applyReason": "我是企微    支持",
          "extraInfo": {
            "reason": "我是企微    支持",
            "remarks": "",
            "wxTicket": "",
            "openimAddContactRspTicket": "<省略>",
            "realRemark": "",
            "applySource": {
              "source": 51
            },
            "remarkUrl": "",
            "addCustomerTime": 1785303706,
            "companyRemark": "",
            "remarkTime": 1
          },
          "sourceInfo": {
            "sourceType": 1,
            "applyMode": 2
          }
        },
        "createSeq": 11195320,
        "DataType": 0
      },
      {
        "id": 7881302241438345,
        "itemFlag": 0,
        "seq": 11195356,
        "createTime": 1785290402,
        "updateTime": 1787909237,
        "content": {
          "userInfo": {
            "uin": 7881302241438345,
            "name": "星云API技术支持",
            "gender": 1,
            "iconUrl": "https://example.com/...",
            "corpId": 1970325134026788,
            "unionId": "oXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          "corpInfo": {},
          "flag": 2057,
          "applyReason": "",
          "extraInfo": {
            "remarks": "",
            "wxTicket": "",
            "realRemark": "星云API技术服务",
            "applySource": {
              "source": 103
            },
            "remarkUrl": "",
            "remarkPhone": [
              {
                "phone": "138****8888"
              }
            ],
            "addCustomerTime": 1787542586,
            "companyRemark": "",
            "labelId": [
              {
                "labelId": "14073752403975683",
                "corpOrVid": 1688850000000000,
                "groupId": "14073752507970986",
                "businessType": 0,
                "serviceGroupId": 0
              },
              {
                "labelId": "14073752410971742",
                "corpOrVid": 1688850000000000,
                "groupId": "14073752507970986",
                "businessType": 0,
                "serviceGroupId": 0
              },
              {
                "labelId": "14073752507970989",
                "corpOrVid": 1970324952577074,
                "groupId": "14073752507970987",
                "businessType": 0,
                "serviceGroupId": 0
              }
            ],
            "isFirstChat": true,
            "remarkTime": 1787630130
          },
          "sourceInfo": {
            "sourceType": 1,
            "applyMode": 1
          }
        },
        "createSeq": 11195340,
        "DataType": 0
      },
      {
        "id": 7881303246306300,
        "itemFlag": 0,
        "seq": 11195358,
        "createTime": 1785202065,
        "updateTime": 1787910936,
        "content": {
          "userInfo": {
            "uin": 7881303246306300,
            "name": "星云API",
            "gender": 0,
            "iconUrl": "https://example.com/...",
            "corpId": 1970325134026788,
            "unionId": "oXXXXXXXXXXXXXXXXXXXXXXXX"
          },
          "corpInfo": {},
          "flag": 2057,
          "applyReason": "我是示例企业的示例名称,添加我的企业微信与我联系吧。",
          "extraInfo": {
            "reason": "我是示例企业的示例名称,添加我的企业微信与我联系吧。",
            "remarks": "",
            "wxTicket": "",
            "realRemark": "星云API",
            "applySource": {
              "source": 4
            },
            "remarkUrl": "",
            "addCustomerTime": 1785747896,
            "companyRemark": "",
            "labelId": [
              {
                "labelId": "14073752410971742",
                "corpOrVid": 1688850000000000,
                "groupId": "14073752507970986",
                "businessType": 0,
                "serviceGroupId": 0
              },
              {
                "labelId": "14073752507970988",
                "corpOrVid": 1970324952577074,
                "groupId": "14073752507970987",
                "businessType": 0,
                "serviceGroupId": 0
              }
            ],
            "isFirstChat": true,
            "remarkTime": 1787629654
          },
          "sourceInfo": {
            "sourceType": 2,
            "applyMode": 1
          }
        },
        "createSeq": 11195329,
        "DataType": 0
      }
    ]
  }
}

返回接口目录 · 请求规范 · 错误码

在线调试

在控制台中在线测试 API 接口无需编码,快速验证接口效果。

基础信息

Base URL复制
https://api.xingyapi.com
API Key复制
X-Nebula-Key: <API Key>
Content-Type
application/json

联系客服

客服微信二维码
微信号:xingyunbot
扫码或搜索微信号,添加客服获取支持