Skip to content
POST{BASE_URL}/wx-api/api/message/groupSendPending
写操作消息JSON · Bearer App Token · body appid

群发助手-发送(待发送消息)

把「待发送」队列里的某条任务真正下发。

请求参数

参数必填类型说明
appidstring实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx
idint64取自获取待发送群发列表的待发送项 id。示例:117159486110430465
contentListarray<object>必须原样取自获取待发送群发列表返回的待发送项,含 appInfo,不能自己拼。示例:[{"contentType":0,"content":[{"type":0,"text":"示例文本"}],"a…
conversationTypeint640 客户 / 1 群。示例:0
contentList[] 字段
字段类型说明
contentList[].contentTypeint64消息类型码(0 文本/14 图片/23 视频…)
contentList[].contentarray<object>消息内容;文本为数组、媒体为对象
contentList[].content[].typeint64类型编码(具体含义随所在对象:成员/部门、图片/视频、节点类型等,详见对应接口)
contentList[].content[].textstringtype 0/3 的文本内容
contentList[].appInfostring企微内部透传串(base64);群发/待发送场景需回填,业务方不必解析

请求示例

http
POST {BASE_URL}/wx-api/api/message/groupSendPending
Authorization: Bearer <你的 App Token>
Content-Type: application/json

{
  "appid": "we_xxxxxxxxxxxxxxx",
  "id": 117159486110430465,
  "contentList": [
    {
      "contentType": 0,
      "content": [
        {
          "type": 0,
          "text": "示例文本"
        }
      ],
      "appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
    }
  ],
  "conversationType": 0
}
bash
curl -X POST '{BASE_URL}/wx-api/api/message/groupSendPending' \
  -H 'Authorization: Bearer <你的 App Token>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "appid": "we_xxxxxxxxxxxxxxx",
  "id": 117159486110430465,
  "contentList": [
    {
      "contentType": 0,
      "content": [
        {
          "type": 0,
          "text": "示例文本"
        }
      ],
      "appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
    }
  ],
  "conversationType": 0
}'
python
import requests

url = "{BASE_URL}/wx-api/api/message/groupSendPending"
headers = {"Authorization": "Bearer <你的 App Token>", "Content-Type": "application/json"}
body = """{
  "appid": "we_xxxxxxxxxxxxxxx",
  "id": 117159486110430465,
  "contentList": [
    {
      "contentType": 0,
      "content": [
        {
          "type": 0,
          "text": "示例文本"
        }
      ],
      "appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
    }
  ],
  "conversationType": 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/message/groupSendPending";
String body = "{\n" +
    "  \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
    "  \"id\": 117159486110430465,\n" +
    "  \"contentList\": [\n" +
    "    {\n" +
    "      \"contentType\": 0,\n" +
    "      \"content\": [\n" +
    "        {\n" +
    "          \"type\": 0,\n" +
    "          \"text\": \"示例文本\"\n" +
    "        }\n" +
    "      ],\n" +
    "      \"appInfo\": \"CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ=\"\n" +
    "    }\n" +
    "  ],\n" +
    "  \"conversationType\": 0\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/message/groupSendPending';
$body = <<<'JSON'
{
  "appid": "we_xxxxxxxxxxxxxxx",
  "id": 117159486110430465,
  "contentList": [
    {
      "contentType": 0,
      "content": [
        {
          "type": 0,
          "text": "示例文本"
        }
      ],
      "appInfo": "CAQQiaO51AYY4Y+oq5SAgAMg56GIsQQ="
    }
  ],
  "conversationType": 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;

响应示例

解析响应前确认字段

返回字段见消息模块总览。完整响应格式及未列出的字段,请通过开通与支持联系对接人确认后再解析。

响应字段

字段类型说明
codeint64统一封套状态码:0=成功,负数=失败
detailstring附加明细,通常为空
messagestring文案:成功为 ok;失败形如 -码|描述
timestring服务端处理时间 YYYY-MM-DD HH:MM:SS

常见错误

下表为企微错误码。业务失败时顶层 code=-1,具体错误码在 message| 前,例如 -3004|参数错误;鉴权与网关错误见错误码

错误码含义怎么办
-24001155群发助手无法发送一年前的任务检查任务 id

下一步