Appearance
操作标签/标签组(个/企)
新增 / 删除 / 修改标签或标签组。改完用 label/sync 拉回最新态。
说明与注意
- 服务端标记该接口为开发中,响应结构可能变动。
请求参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
appid | 是 | string | 实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx |
opScene | 是 | int64 | 操作场景:仅新增企业标签组传 1,其余固定 2。示例:2 |
labelType | 是 | int64 | 标签类型:1 企业标签、2 个人标签。示例:1 |
operItems | 是 | array<object> | 标签操作项列表。示例:[{"op":2,"label":{"id":14073752025997020,"name":"老王","dat… |
operItems[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
operItems[].op | int64 | 操作:1 新增 / 2 删除 / 3 修改 |
operItems[].label | object | 完整标签对象(须原样取自本接口响应) |
operItems[].label.id | int64 | 标签 id |
operItems[].label.name | string | 标签名 |
operItems[].label.dataType | int64 | 数据类型:1 标签、2 标签组 |
operItems[].label.bDeleted | int64 | 是否已删除(0/1) |
operItems[].label.labelGroupId | int64 | 所属标签组 id |
operItems[].label.createTime | int64 | 建立 / 更新时间戳(秒) |
operItems[].label.labelType | int64 | 标签类型:1 企业标签、2 个人标签 |
operItems[].label.businessType | int64 | 业务类型 / 排序 / 服务组 id(原样回传) |
operItems[].label.order | int64 | 业务类型 / 排序 / 服务组 id(原样回传) |
operItems[].label.serviceGroupId | int64 | 业务类型 / 排序 / 服务组 id(原样回传) |
请求示例
http
POST {BASE_URL}/wx-api/api/label/operate
Authorization: Bearer <你的 App Token>
Content-Type: application/json
{
"appid": "we_xxxxxxxxxxxxxxx",
"opScene": 2,
"labelType": 1,
"operItems": [
{
"op": 2,
"label": {
"id": 14073752025997020,
"name": "老王",
"dataType": 1,
"bDeleted": 0,
"labelGroupId": 14073751126007793,
"createTime": 1787907966,
"labelType": 1,
"businessType": 0,
"order": 0,
"serviceGroupId": 0
}
}
]
}bash
curl -X POST '{BASE_URL}/wx-api/api/label/operate' \
-H 'Authorization: Bearer <你的 App Token>' \
-H 'Content-Type: application/json' \
--data-raw '{
"appid": "we_xxxxxxxxxxxxxxx",
"opScene": 2,
"labelType": 1,
"operItems": [
{
"op": 2,
"label": {
"id": 14073752025997020,
"name": "老王",
"dataType": 1,
"bDeleted": 0,
"labelGroupId": 14073751126007793,
"createTime": 1787907966,
"labelType": 1,
"businessType": 0,
"order": 0,
"serviceGroupId": 0
}
}
]
}'python
import requests
url = "{BASE_URL}/wx-api/api/label/operate"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
"appid": "we_xxxxxxxxxxxxxxx",
"opScene": 2,
"labelType": 1,
"operItems": [
{
"op": 2,
"label": {
"id": 14073752025997020,
"name": "老王",
"dataType": 1,
"bDeleted": 0,
"labelGroupId": 14073751126007793,
"createTime": 1787907966,
"labelType": 1,
"businessType": 0,
"order": 0,
"serviceGroupId": 0
}
}
]
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String url = "{BASE_URL}/wx-api/api/label/operate";
String body = "{\n" +
" \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
" \"opScene\": 2,\n" +
" \"labelType\": 1,\n" +
" \"operItems\": [\n" +
" {\n" +
" \"op\": 2,\n" +
" \"label\": {\n" +
" \"id\": 14073752025997020,\n" +
" \"name\": \"老王\",\n" +
" \"dataType\": 1,\n" +
" \"bDeleted\": 0,\n" +
" \"labelGroupId\": 14073751126007793,\n" +
" \"createTime\": 1787907966,\n" +
" \"labelType\": 1,\n" +
" \"businessType\": 0,\n" +
" \"order\": 0,\n" +
" \"serviceGroupId\": 0\n" +
" }\n" +
" }\n" +
" ]\n" +
"}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer <你的 App Token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());php
<?php
$url = '{BASE_URL}/wx-api/api/label/operate';
$body = <<<'JSON'
{
"appid": "we_xxxxxxxxxxxxxxx",
"opScene": 2,
"labelType": 1,
"operItems": [
{
"op": 2,
"label": {
"id": 14073752025997020,
"name": "老王",
"dataType": 1,
"bDeleted": 0,
"labelGroupId": 14073751126007793,
"createTime": 1787907966,
"labelType": 1,
"businessType": 0,
"order": 0,
"serviceGroupId": 0
}
}
]
}
JSON;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer <你的 App Token>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;响应示例
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
code | int64 | 统一封套状态码:0=成功,负数=失败 |
detail | string | 附加明细,通常为空 |
message | string | 文案:成功为 ok;失败形如 -码|描述 |
time | string | 服务端处理时间 YYYY-MM-DD HH:MM:SS |