Files
2025-11-18 18:29:15 +08:00

107 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# API 使用说明
Message Nest 提供统一的消息推送API接口。
## 接口地址
```
POST /api/v1/message/send
```
## 请求参数
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| token | string | 是 | 推送令牌,在管理后台查看 |
| title | string | 是 | 消息标题 |
| text | string | 是 | 消息内容 |
## 请求示例
```json
{
"token": "a3541c2f0d3e1b4a5c6d7e8f9a0b1c2d3e",
"title": "message title",
"text": "Hello World!"
}
```
## 响应格式
### 成功响应
```json
{
"code": 200,
"msg": "success",
"data": {
"status": "sent"
}
}
```
### 失败响应
```json
{
"code": 400,
"msg": "error message",
"data": null
}
```
## 获取 Token
1. 登录 Message Nest 管理后台
2. 进入"发送任务"页面
3. 创建新的发送任务
4. 配置推送渠道(邮件、钉钉、企业微信等)
5. 保存后获得推送令牌(Token
## 支持的推送渠道
- **邮件** - SMTP邮件发送
- **钉钉** - 钉钉机器人
- **企业微信** - 企业微信应用消息
- **微信公众号** - 微信测试公众号模板消息
- **自定义Webhook** - 自定义HTTP请求
- **自托管消息** - 站内消息
## 使用流程
1. **创建推送渠道**
- 在管理后台配置各种推送渠道
- 填写相应的配置信息(如邮箱、Webhook地址等)
2. **创建发送任务**
- 选择要使用的推送渠道
- 可以选择多个渠道同时推送
- 获得唯一的推送令牌(Token
3. **调用API发送消息**
- 使用获得的 Token
- 发送标题和内容
- 消息会自动推送到配置的所有渠道
## 注意事项
::: warning 重要
- Token 是唯一的,请妥善保管
- 消息内容支持纯文本和Markdown格式(取决于推送渠道)
- 建议使用异步方式调用API,避免阻塞主流程
:::
## 错误码说明
| 错误码 | 说明 |
|--------|------|
| 200 | 成功 |
| 400 | 请求参数错误 |
| 401 | 未授权 |
| 404 | Token不存在 |
| 500 | 服务器内部错误 |
## 下一步
查看各语言的 [调用示例](/api/examples)。