Skip to content
POST{BASE_URL}/api/message/sendQuote
写操作已实测消息JSON · Bearer 调用凭证 · body appid

发送引用消息 ​

引用一条消息回复,对方看到的是「发送人:原文」加你的回复。

说明与注意 ​

  • message 要把被引用的消息对象整个原样传:发送接口返回的 data、同步消息或推送里的消息都行;只传 id 报 unexpected end of JSON input。
  • message.content 必须是 [{type, text}] 数组,不能是 base64 原文;content 也是数组,传字符串报类型错。
  • 引用前缀「发送人:原文」由服务端拼好,返回的 content 变成 4 段,flag 为 512;不要自己在 content 里写前缀。

请求参数 ​

参数必填类型说明
appid是string实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx
conversationId是int64被引用消息所在的会话:单聊填对方 userId,群聊填 roomId;必须是 JSON number。示例:7881300000000002
senderAvatarUrl否string发送人头像地址,可传空串
content是array<object>回复正文,[{type, text}] 数组。示例:[{"type":0,"text":"收到,马上处理"}]
message是object被引用的原始消息对象,整个原样传
content[] 字段
字段类型说明
content[].typeinteger0 文本
content[].textstring文本内容
message 字段
字段类型说明
message.idint64消息 id
message.fromUserIdint64原消息发送方
message.toUserIdint64原消息接收方
message.roomIdint64群会话 id,单聊为 0
message.contentTypeinteger原消息类型码
message.sendTimeint64原消息发送时间,秒级时间戳
message.senderNamestring原消息发送人的名字,决定引用前缀里显示的名字
message.contentarray<object>原消息内容,[{type, text}] 数组

请求示例 ​

http
POST {BASE_URL}/api/message/sendQuote
Authorization: Bearer <你的调用凭证>
Content-Type: application/json

{
  "appid": "we_xxxxxxxxxxxxxxx",
  "conversationId": 7881300000000002,
  "senderAvatarUrl": "",
  "content": [
    {
      "type": 0,
      "text": "收到,马上处理"
    }
  ],
  "message": {
    "id": 1001088,
    "messageType": 0,
    "fromUserId": 7881300000000002,
    "toUserId": 1688850000000001,
    "roomId": 0,
    "contentType": 0,
    "sendTime": 1794475969,
    "senderName": "李**",
    "content": [
      {
        "type": 0,
        "text": "发票什么时候能开?"
      }
    ]
  }
}
bash
curl -X POST '{BASE_URL}/api/message/sendQuote' \
  -H 'Authorization: Bearer <你的调用凭证>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "appid": "we_xxxxxxxxxxxxxxx",
  "conversationId": 7881300000000002,
  "senderAvatarUrl": "",
  "content": [
    {
      "type": 0,
      "text": "收到,马上处理"
    }
  ],
  "message": {
    "id": 1001088,
    "messageType": 0,
    "fromUserId": 7881300000000002,
    "toUserId": 1688850000000001,
    "roomId": 0,
    "contentType": 0,
    "sendTime": 1794475969,
    "senderName": "李**",
    "content": [
      {
        "type": 0,
        "text": "发票什么时候能开?"
      }
    ]
  }
}'
python
import requests

url = "{BASE_URL}/api/message/sendQuote"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
  "appid": "we_xxxxxxxxxxxxxxx",
  "conversationId": 7881300000000002,
  "senderAvatarUrl": "",
  "content": [
    {
      "type": 0,
      "text": "收到,马上处理"
    }
  ],
  "message": {
    "id": 1001088,
    "messageType": 0,
    "fromUserId": 7881300000000002,
    "toUserId": 1688850000000001,
    "roomId": 0,
    "contentType": 0,
    "sendTime": 1794475969,
    "senderName": "李**",
    "content": [
      {
        "type": 0,
        "text": "发票什么时候能开?"
      }
    ]
  }
}"""

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}/api/message/sendQuote";
String body = "{\n" +
    "  \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
    "  \"conversationId\": 7881300000000002,\n" +
    "  \"senderAvatarUrl\": \"\",\n" +
    "  \"content\": [\n" +
    "    {\n" +
    "      \"type\": 0,\n" +
    "      \"text\": \"收到,马上处理\"\n" +
    "    }\n" +
    "  ],\n" +
    "  \"message\": {\n" +
    "    \"id\": 1001088,\n" +
    "    \"messageType\": 0,\n" +
    "    \"fromUserId\": 7881300000000002,\n" +
    "    \"toUserId\": 1688850000000001,\n" +
    "    \"roomId\": 0,\n" +
    "    \"contentType\": 0,\n" +
    "    \"sendTime\": 1794475969,\n" +
    "    \"senderName\": \"李**\",\n" +
    "    \"content\": [\n" +
    "      {\n" +
    "        \"type\": 0,\n" +
    "        \"text\": \"发票什么时候能开?\"\n" +
    "      }\n" +
    "    ]\n" +
    "  }\n" +
    "}";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
    .header("Authorization", "Bearer <你的调用凭证>")
    .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}/api/message/sendQuote';
$body = <<<'JSON'
{
  "appid": "we_xxxxxxxxxxxxxxx",
  "conversationId": 7881300000000002,
  "senderAvatarUrl": "",
  "content": [
    {
      "type": 0,
      "text": "收到,马上处理"
    }
  ],
  "message": {
    "id": 1001088,
    "messageType": 0,
    "fromUserId": 7881300000000002,
    "toUserId": 1688850000000001,
    "roomId": 0,
    "contentType": 0,
    "sendTime": 1794475969,
    "senderName": "李**",
    "content": [
      {
        "type": 0,
        "text": "发票什么时候能开?"
      }
    ]
  }
}
JSON;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer <你的调用凭证>',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

响应示例 ​

json
{
  "code": 0,
  "data": {
    "id": 1001090,
    "messageType": 0,
    "fromUserId": 1688850000000001,
    "toUserId": 7881300000000002,
    "roomId": 0,
    "contentType": 0,
    "sendTime": 1794475969,
    "content": [
      {
        "type": 0,
        "text": "“李**:\n"
      },
      {
        "type": 0,
        "text": "发票什么时候能开?"
      },
      {
        "type": 0,
        "text": "”\n------\n"
      },
      {
        "type": 0,
        "text": "收到,马上处理"
      }
    ],
    "flag": 512
  },
  "detail": "",
  "message": "ok",
  "time": "2026-11-12 17:32:53"
}

响应字段 ​

响应字段(14 项)
字段类型说明
codeint64统一封套状态码:0=成功,负数=失败
dataobject刚发出的引用消息
data.idint64消息 id
data.messageTypeinteger消息大类,0 普通消息
data.fromUserIdint64发送方,即当前账号
data.toUserIdint64接收方
data.roomIdint64群会话 id,单聊为 0
data.contentTypeinteger0
data.sendTimeint64发送时间,秒级时间戳
data.contentarray<object>4 段:引用前缀、原文、分隔线、你的回复
data.flaginteger512 表示引用消息
detailstring附加明细,通常为空
messagestring文案:成功为 ok;失败形如 -码|描述
timestring服务端处理时间 YYYY-MM-DD HH:MM:SS

常见错误 ​

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

错误码含义怎么办
-4014conversationId 不属于当前账号:过期或错误的 uin,或不是本账号的联系人、群先调获取个人信息取当前 uin,核对会话 id
-3020把自聊会话的 roomId 当成了发送目标给自己发用当前账号 uin
-3004参数错误检查字段名与类型,数字 id 不能传字符串

下一步 ​