跳转到内容

使用手册

公开 API 的基址是 https://api.messagerouter.dev。/v1/* 使用在 Dashboard「设置」页面创建的 API Key,或 OAuth Bearer Token。请求需要:

Authorization: Bearer <API_KEY>
终端窗口
curl -X POST "https://api.messagerouter.dev/v1/events" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"source_event_id": "ext-001",
"type": "message.link",
"actor": { "source_user_id": "u001", "display_name": "demo" },
"payload": {
"text": "推荐阅读 https://example.com/article/1",
"url": "https://example.com/article/1",
"title": "Example Article"
}
}'
终端窗口
curl "https://api.messagerouter.dev/v1/events?limit=20" \
-H "Authorization: Bearer <API_KEY>"

事件详情:

终端窗口
curl "https://api.messagerouter.dev/v1/events/<event_id>" \
-H "Authorization: Bearer <API_KEY>"

主动发送文本消息使用 POST /v1/messages/send:

终端窗口
curl -X POST "https://api.messagerouter.dev/v1/messages/send" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"bind_id": "bind_01JD8",
"text": "你好",
"target": {
"chat_id": "123456"
}
}'

按原始事件上下文回复使用 POST /v1/messages/reply:

终端窗口
curl -X POST "https://api.messagerouter.dev/v1/messages/reply" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"event_id": "<event_id>",
"text": "已收到",
"bind_id": "bind_01JD8"
}'

兼容端点 POST /v1/events/:id/reply 仍可用于事件回复:

终端窗口
curl -X POST "https://api.messagerouter.dev/v1/events/<event_id>/reply" \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"text": "已收到",
"bind_id": "bind_01JD8"
}'

创建 ConnectorBind 时必须提供 category:

{
"name": "Telegram 通知",
"type": "telegram",
"category": "Platform",
"config": {
"bot_token": "123456:ABC-DEF",
"chat_id": "123456"
}
}

推荐在平台侧填写 bind webhook 地址:

https://api.messagerouter.dev/connectors/<bind_id>/webhook

GET 用于平台地址验证,POST 用于接收消息事件。

事件被接收后,MessageRouter 在后台:

  1. 按优先级匹配你已启用的路由规则。
  2. 对命中的规则依次执行 store、agent、notify、http、transform、moderate 等 action。
  3. 失败的 action 会自动重试;执行结果、错误信息和重试次数记录在执行日志中。

store action 目前保留类型,不执行实际写入。

  • 401: 检查 Authorization: Bearer <API_KEY>,并在「设置」页面确认该 Key 未被吊销。
  • 路由未执行: 检查路由是否启用,用 POST /v1/routes/test 测试匹配,并在 Dashboard「执行日志」或 GET /v1/route-logs 查看结果。