⚡ Agent 接入文档

通过一个 HTTP 请求把结果推给用户. 单 Key = 单用户.

1. 拿到 API Key

登录 web 后台 → API Keys → 创建 Key. 明文只显示一次, 立即保存.

Key 格式: ak_xxxxxxxxxxxx

2. 调用 /notify

所有字段:

字段必填说明
title标题, ≤200 字符
body正文. type=html 时会被 DOMPurify 清洗 (script/iframe 移除)
typetext(默认) / md / html / link
urltype=link 时附带的链接; http(s) 协议白名单
ttl消息存活秒数 (覆盖默认保留期), 上限 365 天

curl

curl -X POST https://notify.ztsy.top/notify \
  -H "X-API-Key: ak_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "任务完成",
    "body": "agent 跑完了, 结果在附件",
    "type": "text"
  }'

Python (requests)

import requests
requests.post(
    "https://notify.ztsy.top/notify",
    headers={"X-API-Key": "ak_xxxxxxxxxxxx"},
    json={"title": "任务完成", "body": "结果...", "type": "text"},
)

JavaScript (fetch)

await fetch("https://notify.ztsy.top/notify", {
  method: "POST",
  headers: {
    "X-API-Key": "ak_xxxxxxxxxxxx",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ title: "任务完成", body: "结果...", type: "text" }),
});

3. 响应

成功 (200):

{
  "id": 1234,
  "delivered": false,
  "online": 0,
  "quota": { "used": 5, "limit": 100000 }
}

online 是当前 WebSocket 在线客户端数 (Android 走 MQTT, 不计入).

4. type 类型

5. 错误码

HTTPerror说明
401invalid_api_keyKey 不存在/已撤销
400title_requiredtitle 为空
400invalid_typetype 不是 text/md/html/link
400unsafe_urlurl 协议不是 http(s)
413body_too_largebody 超过 max_body_size
429rate_limited触发限流 (IP/用户/Key 维度)
429quota_exceeded每日配额用完 (free 1000/天, vip 100000/天)

6. 限流 / 配额

7. 机器可读文档

agent 可拉 /api/docs 拿 JSON 格式的同样信息 (字段定义 + 错误码).


服务器地址: https://notify.ztsy.top · 登录 · 健康检查