服务端 API
发送单聊消息后
在单聊消息发送完成后同步消息事件。
触发时机
| 项目 | 说明 |
|---|---|
| 类型 | 后置回调 |
| 配置项 | afterSendSingleMsg |
| 回调命令 | callbackAfterSendSingleMsgCommand |
HTTP 请求
POST {WEBHOOK_ADDRESS}/callbackAfterSendSingleMsgCommand
Content-Type: application/json
operationID: {OPERATION_ID}{
"sendID": "user_001",
"recvID": "user_001",
"callbackCommand": "callbackAfterSendSingleMsgCommand",
"serverMsgID": "server_msg_001",
"clientMsgID": "client_msg_001",
"operationID": "operation_001",
"senderPlatformID": 1,
"senderNickname": "user_001",
"sessionType": 1,
"msgFrom": 1,
"contentType": 1,
"status": 1,
"sendTime": 1719800000000,
"createTime": 1719800000000,
"content": "{\"text\":\"hello\"}",
"seq": 1,
"atUserList": ["user_001"],
"faceURL": "https://example.com/avatar.png",
"ex": "",
"keyVersion": 1
}请求体参数
| 参数名 | 是否必填 | 类型 | 说明 |
|---|---|---|---|
| sendID | 是 | string | 消息发送者用户 ID。 |
| recvID | 是 | string | 消息接收者用户 ID;单聊时为对端用户 ID。 |
| callbackCommand | 是 | string | 回调命令,值与当前页面的回调命令一致。 |
| serverMsgID | 是 | string | OpenIM 服务端消息 ID。 |
| clientMsgID | 是 | string | 客户端消息 ID。 |
| operationID | 是 | string | OpenIM 操作的链路追踪 ID。 |
| senderPlatformID | 是 | int | 发送端平台 ID,参见用户模块的 PlatformID。 |
| senderNickname | 是 | string | 发送者昵称。 |
| sessionType | 是 | int | 会话类型,参见会话模块的 ConversationType。 |
| msgFrom | 是 | int | msgFrom 字段。 |
| contentType | 是 | int | 消息内容类型,参见消息内容类型。 |
| status | 是 | int | status 字段。 |
| sendTime | 是 | int | sendTime 字段。 |
| createTime | 是 | int | createTime 字段。 |
| content | 是 | string | 消息内容;通常是与消息类型对应的 JSON 字符串。 |
| seq | 是 | int | 消息或连接序列号。 |
| atUserList | 是 | string[] | 被 @ 的用户 ID 列表。 |
| faceURL | 是 | string | 头像地址。 |
| ex | 是 | string | 业务扩展字段。 |
| keyVersion 商业版 | 是 | int | 消息加密密钥版本号。 |
响应
业务服务端应返回 HTTP 成功状态和 JSON 响应体。
{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0
}响应参数
| 参数名 | 类型 | 说明 |
|---|---|---|
| actionCode | int | 处理状态,参见Webhooks 概述的 CallbackAction。 |
| errCode | int | 业务错误码;拒绝前置操作时返回业务约定的非零错误码。 |
| errMsg | string | 错误简要信息。 |
| errDlt | string | 错误详细信息。 |
| nextCode | int | 处理下一步,参见Webhooks 概述的 CallbackNextCode。 |
处理规则
- 事件发生后,OpenIM 异步调用该地址。
- 回调响应不能改变已经完成的 OpenIM 操作。
- 接收方应快速返回成功状态,再异步执行耗时业务。
- 接收方应按业务主键或
operationID做幂等处理。
相关页面
这个页面有帮助吗?