接口调用说明
通过该接口查询指定会话的聊天记录
请求URL示例
https://console.tim.qq.com/v4/desk_http_svc/describe_chat_messages?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
请求参数说明
参数 | 说明 |
v4/desk_http_svc/describe_chat_messages | 请求接口。 |
sdkappid | 创建应用时即时通信 IM 控制台分配的 SDKAppID。 |
identifier | |
usersig | |
random | 请输入随机的32位无符号整数,取值范围0 - 4294967295。 |
contenttype | 请求格式固定值为 json 。 |
请求包示例
{"SessionId": "b0f4ca12-4850-4218-a284-efe679a87066","Limit": 50,"Offset": 0,"Order": 1}
请求包字段说明
字段 | 类型 | 属性 | 说明 |
SessionId | String | 必填 | 指定要查询的会话 ID |
Limit | Integer | 选填 | 返回记录条数,最大为100默认20 示例值:100 |
Offset | Integer | 选填 | 返回记录偏移,默认为 0 示例值:0 |
Order | Integer | 选填 | 1为从早到晚,2为从晚到早,默认为2 示例值:1 |
应答包体示例
{"ActionStatus": "OK","ErrorCode": 0,"ErrorInfo": "","Messages": [{"FromAccount": "8618655061639","FromAccountRole": 1,"MsgBody": [{"MsgContent": {"Text": "hello"},"MsgType": "TIMTextElem"}],"Timestamp": 1730939030138}],"TotalCount": 26}
应答包字段说明
字段 | 类型 | 说明 |
ErrorCode | Integer | 错误码: 0表示成功。 非0表示失败。 |
ErrorInfo | String | 错误信息。 |
ActionStatus | String | 请求处理的结果。 |
TotalCount | Integer | 总消息数 |
Messages | Array | 查询到的消息列表 |
FromAccount | String | 消息发送账号 |
FromAccountRole | Integer | 消息发送账号角色 1:用户消息 2:客服消息 3:系统管理消息 |
MsgBody | Array | |
Timestamp | Integer | 会话时间,Unix 毫秒级时间戳 |
错误码说明
除非发生网络错误(例如502错误),否则该接口的 HTTP 返回码均为200。真正的错误码,错误信息是通过应答包体中的 ErrorCode、ErrorInfo 来表示的。
本 API 私有错误码如下:
错误码 | 描述 |
141000 | 该应用非智能客服应用。 |
141002 | 内部错误,请重试。 |
141004 | 参数非法。 |
141009 | 接口限频。 |
141010 | 会话不存在。 |
接口调试工具