批量发送消息
向多个用户批量发送相同内容的消息。
接口信息
| 属性 | 值 |
|---|---|
| 请求方式 | POST |
| 请求路径 | /v1/message/batch-send |
| 鉴权方式 | App Token |
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| receive_ids | string[] | 是 | 接收者 ID 列表,最多 200 个 |
| msg_type | string | 是 | 消息类型 |
| content | object | 是 | 消息内容 |
请求示例
curl -X POST 'https://api.im.example.com/v1/message/batch-send' \
-H 'Authorization: Bearer t-xxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"receive_ids": ["user_001", "user_002", "user_003"],
"msg_type": "text",
"content": {
"text": "系统维护通知:今晚 22:00-24:00 进行系统升级"
}
}'
响应参数
| 参数 | 类型 | 说明 |
|---|---|---|
| success_count | number | 成功发送数量 |
| fail_count | number | 失败数量 |
| fail_list | array | 失败详情列表 |
响应示例
{
"code": 0,
"msg": "success",
"data": {
"success_count": 2,
"fail_count": 1,
"fail_list": [
{
"receive_id": "user_003",
"error_code": 10301,
"error_msg": "用户不存在"
}
]
}
}
注意事项
- 单次最多发送 200 个用户
- 建议使用异步方式处理大批量发送
- 部分失败不影响其他用户的发送