Appearance
标记会话已读
把一个单聊或群聊会话标记为已读。
说明与注意
- 只能标记为已读;标记未读、清空聊天记录、删除会话不在本接口。
- 成功时
data不是空对象,而是这个会话的最后一条消息。 - 群聊的
roomId是 17 位以上的 int64,JS 里用 BigInt 或 json-bigint 解析,不要转成 Number。
请求参数
| 参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
appid | 是 | string | 实例 appid,标识操作哪个已登录账号。示例:we_xxxxxxxxxxxxxxx |
conversationId | 是 | int64 | 会话 id:单聊传对方 userId,群聊传 roomId,自己的会话传当前账号 uin;必须是 JSON number。示例:1688850000000001 |
unread | 否 | int64 | 可不传;传就传 0,不要传 null。示例:0 |
请求示例
http
POST {BASE_URL}/api/message/sendRead
Authorization: Bearer <你的调用凭证>
Content-Type: application/json
{
"appid": "we_xxxxxxxxxxxxxxx",
"conversationId": 1688850000000001,
"unread": 0
}1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
bash
curl -X POST '{BASE_URL}/api/message/sendRead' \
-H 'Authorization: Bearer <你的调用凭证>' \
-H 'Content-Type: application/json' \
--data-raw '{
"appid": "we_xxxxxxxxxxxxxxx",
"conversationId": 1688850000000001,
"unread": 0
}'1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
python
import requests
url = "{BASE_URL}/api/message/sendRead"
headers = {"Authorization": "Bearer <你的调用凭证>", "Content-Type": "application/json"}
body = """{
"appid": "we_xxxxxxxxxxxxxxx",
"conversationId": 1688850000000001,
"unread": 0
}"""
resp = requests.post(url, headers=headers, data=body.encode("utf-8"))
print(resp.text)1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
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/sendRead";
String body = "{\n" +
" \"appid\": \"we_xxxxxxxxxxxxxxx\",\n" +
" \"conversationId\": 1688850000000001,\n" +
" \"unread\": 0\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());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
php
<?php
$url = '{BASE_URL}/api/message/sendRead';
$body = <<<'JSON'
{
"appid": "we_xxxxxxxxxxxxxxx",
"conversationId": 1688850000000001,
"unread": 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 <你的调用凭证>',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
响应示例
json
{
"code": 0,
"data": {
"id": 1000458,
"syncKey": 12729027,
"messageType": 0,
"fromUserId": 1688850000000001,
"toUserId": 1688850000000001,
"roomId": 0,
"contentType": 2001,
"sendTime": 1794305170,
"appInfo": "<base64>",
"senderName": "张**",
"content": {
"msgType": 2001,
"hex": "080010c2f588062800"
},
"extraData": null,
"flag": 0,
"devInfo": 131075,
"summary": ""
},
"detail": "",
"message": "ok",
"time": "2026-11-10 18:06:10"
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
响应字段
响应字段(20 项)
| 字段 | 类型 | 说明 |
|---|---|---|
code | int64 | 统一封套状态码:0=成功,负数=失败 |
data | object | 该会话的最后一条消息 |
data.id | int64 | 消息 id |
data.syncKey | int64 | 同步序列号 |
data.messageType | int64 | 0 单聊、1 群聊、3 系统通知 |
data.fromUserId | int64 | 发送方 |
data.toUserId | int64 | 接收方 |
data.roomId | int64 | 群消息时为群 id,单聊为 0 |
data.contentType | int64 | 消息类型,示例里的 2001 是系统类消息 |
data.sendTime | int64 | 发送时间,秒级时间戳 |
data.senderName | string | 发送方昵称 |
data.content | object | 消息内容 |
data.content.msgType | int64 | 同 contentType |
data.content.hex | string | 消息体的十六进制原文 |
data.appInfo | string | 透传串,不需要解析 |
data.devInfo | int64 | 设备标记,原样保存即可 |
data.summary | string | 摘要,可能为空串 |
detail | string | 附加明细,通常为空 |
message | string | 文案:成功为 ok;失败形如 -码|描述 |
time | string | 服务端处理时间 YYYY-MM-DD HH:MM:SS |