- API在线调试指南
- IM账号管理
- 用户名片管理
- 好友管理
- 静音管理
- 黑名单管理
- 消息管理
- 会话功能
- 群组功能
- 聊天室功能
- 聊天室管理
- 聊天室成员
- 广播消息管理
- 系统通知管理
- 发布订阅
- 翻译
发送消息
POST
/im/v2/conversations/{conversation_id}/messages
请求参数
Path 参数
conversation_id
string
必需
sender_id|conversation_type|receiver_id
sender_id:会话消息发送者的账号 ID,String 类型
conversation_type:会话类型,1:单聊会话;2:高级群会话;3:超大群会话
receiver_id:接收会话消息的账号 ID 或群组 ID
单聊会话时为消息接收者的账号 ID;高级群会话时为接收消息的高级群 ID;超大群会话时为超大群 ID。
示例值:
apifoxtest1|1|accid4
Header 参数
AppKey
string
必需
默认值:
{{AppKey}}
X-custom-traceid
string
可选
默认值:
{% mock 'uuid' %}
Nonce
string
必需
默认值:
{{Nonce}}
CurTime
string
必需
默认值:
{{CurTime}}
CheckSum
string
必需
默认值:
{{CheckSum}}
Body 参数application/json
sender_no_sense
boolean
发送方无感知
默认值:
false
receiver_no_sense
boolean
接收方无感知
默认值:
false
extension
string
开发者扩展字段
message
object
消息体
message_type
integer
消息类型
sub_type
integer
自定义消息子类型
> 0
text
string
文本消息
<= 500 字符
attachment
object
多媒体消息内容
message_client_id
string
客户端消息id(不传则自动生成)
message_config
object
消息配置
unread_enabled
boolean
未读数
默认值:
true
mutil_sync_enabled
boolean
多端同步
默认值:
true
offline_enabled
boolean
存离线
默认值:
true
history_enabled
boolean
云端历史
默认值:
true
roaming_enabled
boolean
漫游
默认值:
true
conversation_update_enabled
boolean
更新会话
默认值:
true
route_config
object
抄送配置
route_enabled
boolean
是否抄送
默认值:
true
route_environment
string
抄送环境
push_config
object
推送配置
push_enabled
boolean
是否推送
默认值:
true
push_nick_enabled
boolean
推送是否带昵称
默认值:
true
push_content
string
推送文案
<= 500 字符
push_payload
string
推送payload
<= 2048 字符
push_forcepush_all
boolean
是否强制推送
默认值:
false
push_forcepush_ids
array[string]
强推列表
push_forcepush_content
string
强推文案
<= 500 字符
antispam_config
object
安全通配置
antispam_enabled
boolean
安全通开关
默认值:
true
antispam_business_id
string
安全通业务ID
antispam_extension
string
安全通增强参数
antispam_custom_message_enabled
boolean
自定义内容审核开关
默认值:
false
antispam_custom_message
string
自定义安全通检测内容
antispam_cheating
string
反作弊检测参数
p2p_option
object
单聊消息配置
check_friend
boolean
是否校验好友关系
team_option
object
高级群消息配置
mark_as_read
boolean
是否需要已读功能
默认值:
false
check_team_member_valid
boolean
是否需要验证群成员身份
默认值:
true
superteam_option
object
超大群消息配置
ignore_chat_banned
boolean
是否忽略成员禁言
默认值:
false
check_team_member_valid
boolean
是否需要验证群成员身份
默认值:
true
robot_config
object
机器人功能配置
robot_account_id
string
机器人账号 ID
robot_topic
string
机器人消息话题
<= 128 字符
robot_function
string
机器人具体功能
<= 128 字符
robot_custom_content
string
机器人自定义内容
<= 8192 字符
ai_params
object
数字人配置项
account
string
必需
content
object
可选
{ "msg": "xxx",//内容 "type": 0//类型,当前仅支持 0 表示文本 }
如果为空且不是文本消息,则返回 107336 错误。
messages
array [object]
可选
[ { "msg": "hello", "type": 0, "role": "user" }, { "msg": "hello, I am your AI assistant", "type": 0, "role": "assistant" } ]
prompt_variables
object
可选
{ "career":"chef" }
config
object
可选
{"maxTokens":1,"temperature":1,"prompt":"我是一个${{career}},请回答我的问题:","topP":0.5}
target_option
object
群定向消息配置项。
receiver_account_ids
array[string]
群定向消息成员列表,即指定接收群消息的群成员列表。
当 inclusive 为 false,当前列表为不可见(不接收)列表。
列表中不能包含消息发送者,消息发送者默认为可见。
列表中不能包含非法账号、非群成员账号。
列表中最多可以传入 100 个用户账号。
inclusive
boolean
是否为可见列表
发送超大群消息时,不能将 inclusive 设置为 false。
默认值:
true
visible_to_new_member
boolean
新进群成员是否可见该消息
当 inclusive 为 true 时,不能同时设置 visible_to_new_member 为 true。即发送定向列表为可见的定向消息时,只能由定向列表中成员接收和查看。
发送超大群消息时,不能将 visible_to_new_member 设置为 true。
默认值:
false
check_team_member_valid
boolean
是否校验定向成员合法性
thread_config
object (thread_config)
可选
thread_root
object
可选
thread_reply
object
被回复的消息对象。
示例
{
"sender_no_sense": false,
"receiver_no_sense": false,
"extension": "dolore dolor sint qui voluptate",
"message": {
"message_type": 0,
"sub_type": 26357002,
"text": "Lorem laboris cillum ut exercitation",
"attachment": {
"name": "器年众际根开以",
"md5": "esse Excepteur do",
"url": "http://zpcuedkr.nc/yjy",
"ext": "Excepteur consequat",
"width": 83,
"height": 56,
"size": 18
}
},
"message_config": {
"unread_enabled": false,
"mutil_sync_enabled": true,
"offline_enabled": true,
"history_enabled": false,
"roaming_enabled": true,
"conversation_update_enabled": true
},
"route_config": {
"route_enabled": true,
"route_environment": "Lorem anim quis"
},
"push_config": {
"push_enabled": true,
"push_nick_enabled": false,
"push_content": "id do in velit",
"push_payload": null,
"push_forcepush_all": true,
"push_forcepush_ids": [
"22"
],
"push_forcepush_content": "nostrud veniam dolore esse"
},
"antispam_config": {
"antispam_enabled": false,
"antispam_business_id": "44",
"antispam_extension": null,
"antispam_custom_message_enabled": true,
"antispam_custom_message": "laborum non irure et",
"antispam_cheating": "{\"email\":\"123@126.com\"}"
},
"p2p_option": {
"check_friend": true
},
"team_option": {
"mark_as_read": true,
"ignore_chat_banned": false
},
"superteam_option": {
"ignore_chat_banned": false
},
"robot_config": {
"robot_account_id": null,
"robot_topic": "http://dummyimage.com/400x400",
"robot_function": "ex nisi pariatur qui do",
"robot_custom_content": "quis Lorem"
}
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://open.yunxinapi.com/im/v2/conversations/apifoxtest1|1|accid4/messages?members&reference&Type&_postman_listIndexKey=key&_postman_listAllowsMultipleValues' \
--data-raw '{
"sender_no_sense": false,
"receiver_no_sense": false,
"extension": "dolore dolor sint qui voluptate",
"message": {
"message_type": 0,
"sub_type": 26357002,
"text": "Lorem laboris cillum ut exercitation",
"attachment": {
"name": "器年众际根开以",
"md5": "esse Excepteur do",
"url": "http://zpcuedkr.nc/yjy",
"ext": "Excepteur consequat",
"width": 83,
"height": 56,
"size": 18
}
},
"message_config": {
"unread_enabled": false,
"mutil_sync_enabled": true,
"offline_enabled": true,
"history_enabled": false,
"roaming_enabled": true,
"conversation_update_enabled": true
},
"route_config": {
"route_enabled": true,
"route_environment": "Lorem anim quis"
},
"push_config": {
"push_enabled": true,
"push_nick_enabled": false,
"push_content": "id do in velit",
"push_payload": null,
"push_forcepush_all": true,
"push_forcepush_ids": [
"22"
],
"push_forcepush_content": "nostrud veniam dolore esse"
},
"antispam_config": {
"antispam_enabled": false,
"antispam_business_id": "44",
"antispam_extension": null,
"antispam_custom_message_enabled": true,
"antispam_custom_message": "laborum non irure et",
"antispam_cheating": "{\"email\":\"123@126.com\"}"
},
"p2p_option": {
"check_friend": true
},
"team_option": {
"mark_as_read": true,
"ignore_chat_banned": false
},
"superteam_option": {
"ignore_chat_banned": false
},
"robot_config": {
"robot_account_id": null,
"robot_topic": "http://dummyimage.com/400x400",
"robot_function": "ex nisi pariatur qui do",
"robot_custom_content": "quis Lorem"
}
}'
返回响应
🟢200成功
application/json
Body
code
integer
必需
msg
string
必需
data
object
必需
message_server_id
integer
可选
message_client_id
string
可选
message_type
integer
消息类型。
text
string
可选
attachment
object
可选
sub_type
integer
可选
sender_id
string
可选
conversation_type
integer
消息会话类型。
receiver_id
string
可选
create_time
integer <long>
消息发送时间戳。
thread_config
object
可选
示例
{
"code": 200,
"msg": "success",
"data": {
"text": "Lorem laboris cillum ut exercitation",
"attachment": {
"ext": "Excepteur consequat",
"size": 18,
"name": "器年众际根开以",
"width": 83,
"url": "http://zpcuedkr.nc/yjy",
"md5": "esse Excepteur do",
"height": 56
},
"message_server_id": 9899821270208,
"sender_id": "apifoxtest1",
"conversation_type": 1,
"receiver_id": "accid4",
"create_time": 1707035841692,
"message_type": 0,
"sub_type": 26357002
}
}
🟢200请求参数错误
🟢200服务器错误
修改于 2025-03-17 03:27:49