TUNGKAO API 文档
API · telegram_notify

Telegram 通知

通过 TUNGKAO 的机器人在 Telegram 上给你的用户发消息——无需自建机器人。例如到账、订单状态、验证码。

🕒 最近更新: 泰国时间(UTC+07:00) · ✅ 现有代码照常可用,无需修改

🤖 让 AI 帮你写对接代码

复制此链接给 AI 阅读(该 API 的完整 Markdown),或点击下方按钮:自动复制提示词并打开所选 AI,粘贴后告诉它你的语言/框架

https://app.tungkao.com/docs/api/telegram_notify.md?lang=zh-CN
https://api.tungkao.com/changelog/telegram_notify.json

此链接以 JSON 返回该 API 的更新(无需 key,任何域名可访问)。可在后台显示为“更新公告”框,last_updated 变化时标记“新”

复制并打开: 点击 AI 按钮会自动复制提示词,若对话框为空直接粘贴即可

🔑 使用的密钥

在商户后台(API key)创建 telegram_notify 密钥,并在每个请求中发送此 header——其他服务的密钥在这里无效

Authorization: Bearer $TUNGKAO_KEY

📋 步骤

  1. ref is your own name for a recipient (use your member id, e.g. member-1001): A-Z a-z 0-9 _ . : @ - up to 128 chars. Every call refers to the recipient by this ref.
  2. Add a recipient: your server calls POST /v1/telegram/link {ref} → gets data.url (a t.me/…?start=… link) → show it as a “Connect Telegram” button on the member's profile page (valid 30 minutes, single use; request again any time).
  3. The member opens the link → presses Start in Telegram → the bot confirms (Telegram does not let a bot message someone who never pressed Start, so this step cannot be skipped).
  4. Check the connection: GET /v1/telegram/recipients (status = active) — use it to switch your button to “Connected ✓”.
  5. Send: POST /v1/telegram/send with one ref or up to 100 refs; bold text (parse_mode: HTML) and a link button are supported. Per-recipient results are in data.results: sent / not_linked / failed.
  6. Remove a recipient: DELETE /v1/telegram/recipients/{ref}. Members can also send /stop to the bot. If a member blocks the bot, that recipient is paused until they connect again.
  7. Try it without code: TUNGKAO API key page → this key's card → “Set up notifications” has a create-link button (with QR) and a send-test button.

📡 接口调用 + 代码示例

POST/v1/telegram/link
curl -X POST https://api.tungkao.com/v1/telegram/link \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"member-1001"}'
POST/v1/telegram/send
curl -X POST https://api.tungkao.com/v1/telegram/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"member-1001","text":"<b>Payment received</b> 500 THB","parse_mode":"HTML","button":{"text":"View order","url":"https://yourshop.com/orders/1"}}'
GET/v1/telegram/messages
curl -X GET https://api.tungkao.com/v1/telegram/messages \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📚 使用示例

示例 1

Let a member connect Telegram

场景: Member member-1001 wants notifications on Telegram

请求
POST /v1/telegram/link
{
  "ref": "member-1001"
}
响应示例
{
  "success": true,
  "data": {
    "url": "https://t.me/…?start=…"
  }
}

➡️ Give the member the link to tap (valid 30 minutes, once)

示例 2

Notify a payment

场景: 500 THB arrived and you want to notify the member

请求
POST /v1/telegram/send
{
  "ref": "member-1001",
  "text": "<b>Payment received</b> 500 THB",
  "parse_mode": "HTML"
}

➡️ The member gets the message in Telegram right away

示例 3

Message with a link button

场景: You want a button to open the order

请求
POST /v1/telegram/send
{
  "ref": "member-1001",
  "text": "Order #1001 shipped",
  "button": {
    "text": "View order",
    "url": "https://yourshop.com/orders/1001"
  }
}

➡️ A button under the message opens the link

示例 4

Notify several members at once

场景: Announce a promotion to three members

请求
POST /v1/telegram/send
{
  "refs": [
    "member-1001",
    "member-1002",
    "member-1003"
  ],
  "text": "New promotion today"
}

➡️ Sent to each member; check results with GET /v1/telegram/messages

示例 5

A member stops notifications

场景: The member asks to disconnect

请求
DELETE /v1/telegram/recipients/member-1001

➡️ The link is removed; no more messages are sent

💡 更多

📜 此 API 的更新记录

  1. 新增 泰国时间(UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  2. 文档 泰国时间(UTC+07:00)
    Telegram / Discord notifications: step-by-step setup guide on the key card and in the docs (Telegram connect link, add a Discord channel webhook)
  3. 新增 泰国时间(UTC+07:00)
    error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
  4. 新增 泰国时间(UTC+07:00)
    GET /status:按服务显示 API 状态(无需密钥)
  5. 新增 泰国时间(UTC+07:00)
    密钥开关及状态变更时间 + 每个网站每项服务 1 个密钥
  6. 改进 泰国时间(UTC+07:00)
    API v1 永久冻结(仅新增)+ X-Tungkao-Api-Version header + 提前 12 个月的弃用通知
  7. 文档 泰国时间(UTC+07:00)
    每个 API 独立文档页及 AI 链接(10 种语言)
  8. 安全 泰国时间(UTC+07:00)
    每个 API 密钥域名验证(1 密钥 = 1 网站)——现有密钥照常可用
  9. 新增 泰国时间(UTC+07:00)
    可选 HMAC 请求签名——不开启则一切照旧
  10. 上线 泰国时间(UTC+07:00)
    上线 Telegram 和 Discord 通知
  11. 新增 泰国时间(UTC+07:00)
    API 密钥有效期、到期提醒和续期——密钥字符串不变
  12. 新增 泰国时间(UTC+07:00)
    所有服务支持 test 模式密钥(模拟、免费)

✅ 现有代码照常可用,无需修改

🛡️ 稳定性承诺:一次对接,长期可用

🚦 系统状态(GET /status)

随时查看 API 是否正常,无需密钥

GET https://api.tungkao.com/status

curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🏷️ TUNGKAO 署名要求

Powered by TUNGKAO