TUNGKAO API 文档
点击按钮后选择“另存为 PDF”

TUNGKAO API

Discord 通知

API v1 · 最近更新: 泰国时间(UTC+07:00)

https://tungkao.com · https://api.tungkao.com/docs

根据服务条款,使用本服务的页面必须显示指向 https://tungkao.com 的 “Powered by TUNGKAO”(登录/支付可用 “Secured by TUNGKAO”)

API · discord_notify

Discord 通知

向你或客户的 Discord 频道发消息——例如给团队的新订单通知。

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

🤖 让 AI 帮你写对接代码

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

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

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

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

🔑 使用的密钥

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

Authorization: Bearer $TUNGKAO_KEY

📋 步骤

  1. Create a channel webhook in Discord (needs Manage Webhooks): desktop right-click the channel → Edit Channel → Integrations → Webhooks → New Webhook → name it → Copy Webhook URL (mobile: long-press the channel → Edit Channel).
  2. ref is your own name for the channel, e.g. orders-room (A-Z a-z 0-9 _ . : @ - up to 128 chars). One key can hold many channels, each with its own ref.
  3. Add a channel: POST /v1/discord/webhooks {ref, url} — url must start with https://discord.com/api/webhooks/…; it is stored encrypted and never returned. Posting the same ref again replaces that channel's link.
  4. Send: POST /v1/discord/send {ref, text} (up to 2000 chars; @everyone / @here are disabled automatically). Results are in data.results: sent / not_linked / failed.
  5. List channels: GET /v1/discord/recipients. Remove: DELETE /v1/discord/recipients/{ref}. If the webhook is deleted in Discord, the channel is paused and the undelivered message is refunded.
  6. Try it without code: TUNGKAO API key page → this key's card → “Set up notifications”: paste the webhook link, add the channel and send a test.
  7. Do not confuse this with the key's “Webhook URL” setting: that is your server address for receiving events from TUNGKAO, not a Discord channel link.

📡 接口调用 + 代码示例

POST/v1/discord/webhooks
curl -X POST https://api.tungkao.com/v1/discord/webhooks \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"orders-room","url":"https://discord.com/api/webhooks/123/abc…"}'
POST/v1/discord/send
curl -X POST https://api.tungkao.com/v1/discord/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ref":"orders-room","text":"🛒 New order #1001 — 590 THB"}'

📚 使用示例

示例 1

Register a Discord channel

场景: You want new orders posted in #orders

请求
POST /v1/discord/webhooks
{
  "ref": "orders-room",
  "url": "https://discord.com/api/webhooks/123/abc…"
}

➡️ Name it once with ref and use it forever

示例 2

Post a new order

场景: Order #1001 for 590 THB comes in

请求
POST /v1/discord/send
{
  "ref": "orders-room",
  "text": "🛒 New order #1001 — 590 THB"
}

➡️ The message appears in the channel right away

示例 3

Custom sender name

场景: You want the sender to show as “Shop Bot”

请求
POST /v1/discord/send
{
  "ref": "orders-room",
  "text": "Daily sales: 12,400 THB",
  "username": "Shop Bot"
}

➡️ The message shows Shop Bot as the sender

示例 4

Post to several channels

场景: Notify both the admin and the stock channels

请求
POST /v1/discord/send
{
  "refs": [
    "admin-room",
    "stock-room"
  ],
  "text": "Stock low: T-shirt size M"
}

➡️ Posted to every listed channel

示例 5

Check sending history

场景: You want to see which messages failed

请求
GET /v1/discord/messages

➡️ Returns each message with its status

📜 此 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