Một kiểu API cho mọi dịch vụ — Base URL: https://api.tungkao.com
🕒 Cập nhật API mới nhất theo kênh
Toàn hệ thống cập nhật lần cuối:Giờ Thái Lan (UTC+07:00) — 📘 The TrueMoney Wallet docs page is now fully translated into all 10 languages (steps, examples, case table, notes)
✅ Mã cũ vẫn chạy, không cần sửa · /changelog.json (Dạng máy đọc)
Paste it into the AI that maintains your site's code (ChatGPT / Claude / Gemini); it checks and changes only what is needed
import hashlib, hmac, json, os, time, requests
def tungkao(method, path, body=None):
raw = json.dumps(body, separators=(",", ":")) if body else ""
ts = str(int(time.time()))
msg = f"{ts}.{method}.{path}.{hashlib.sha256(raw.encode()).hexdigest()}"
sig = hmac.new(os.environ["TUNGKAO_SIGNING_SECRET"].encode(), msg.encode(), hashlib.sha256).hexdigest()
return requests.request(method, "https://api.tungkao.com" + path, data=raw or None, timeout=30, headers={
"Authorization": f"Bearer {os.environ['TUNGKAO_KEY']}", "Content-Type": "application/json",
"X-Tungkao-Timestamp": ts, "X-Tungkao-Signature": sig}).json()
print(tungkao("GET", "/v1/account"))
Mọi phản hồi là JSON có success và request_id. Lỗi có error.code (vd KEY_EXPIRED, INSUFFICIENT_CREDITS) — xem /errors.
error.user_message is the text to show your own end users (“The system cannot connect to the tungkao.com API. Please contact the administrator.”). It comes with errors an end user cannot fix: HTTP 5xx, SERVICE_PAUSED, INSUFFICIENT_CREDITS and key problems, in the Accept-Language language. Keys with white-label enabled get a message without the tungkao.com name. If the API cannot be reached at all (timeout/network down), show the same text from your own code.
Key hết hạn theo lựa chọn (1–24 tháng hoặc không hết hạn). Nhắc trước 30/7/1 ngày qua webhook api_key.expiring. Gia hạn trong cổng — chuỗi key giữ nguyên.
Xác minh tên miền: mỗi key live gắn với một website. API key → 'Xác minh tên miền' → nhập tên miền, tải tungkao-verify-….html lên https://ten-mien/ (hoặc thêm DNS TXT _tungkao-verify.ten-mien) rồi bấm Xác minh. Key chưa xác minh nhận DOMAIN_NOT_VERIFIED; tên miền đã xác minh không đổi được và tài khoản khác không dùng được.
Lộ khóa bí mật? Bấm 'Đổi key ngay' — không giới hạn, key cũ ngừng ngay. Key chỉ dùng cho dịch vụ của nó (nếu không sẽ là WRONG_PRODUCT).
Nâng cao (tùy chọn): bật 'Ký yêu cầu' trên key để nhận tksign_…; sau đó mọi yêu cầu cần X-Tungkao-Timestamp và X-Tungkao-Signature = HMAC-SHA256(bí mật, ts.METHOD.path.sha256(body)). Chỉ lộ key thì vô dụng.
🧪 Test mode (tk_test_… keys) is free and limited to 2 calls per service per day (non-GET requests only; resets at midnight Bangkok time). Beyond that you get HTTP 429 RATE_LIMITED with a message — use a live key for unlimited calls.
Gửi Accept-Language (th, en, lo, my, zh-CN, ko, ja, vi, km, id) để chọn ngôn ngữ thông báo.
🧾
Kiểm tra biên lai ngân hàng
slip_verify
Kiểm tra biên lai là thật, đúng số tiền, chuyển cho bạn và chưa được dùng — cho cửa hàng có khách đính kèm biên lai.
Cách hoạt động
Khách tải biên lai lên; site đọc văn bản QR (bắt đầu bằng 0041…).
Gửi qr_payload, số tiền mong đợi và tài khoản nhận tới API.
Một biên lai qua được cả hai trang ⚠️ khách có thể nạp hai lần — hãy liên kết key
2 trang có tài khoản nhận khác nhau
Chỉ key này (mặc định)
Biên lai của trang này sang trang kia đã trả RECEIVER_MISMATCH ✅
2 trang thuộc 2 tài khoản tungkao khác nhau (chủ khác) nhưng cùng tài khoản nhận
Không thể liên kết key giữa các tài khoản tungkao
Một biên lai qua cả hai ⚠️ — hãy mua cả hai key từ một tài khoản tungkao và liên kết
Một trang dùng 2 key (vd. web + ứng dụng)
Cả hai key: cùng nhóm
Biên lai chỉ dùng được một lần dù gửi từ web hay ứng dụng ✅
DUPLICATE được phát hiện ngay từ mã tham chiếu trong QR. Cài ở thẻ “Chống dùng lại biên lai giữa các key” trên trang API Keys (key mới mặc định: chỉ key này).
📚 Ví dụ sử dụng
Ví dụ 1
Customer tops up with a matching slip (passes)
Tình huống: A customer transfers 500 THB to your account and uploads the slip on your top-up page
Yêu cầu
POST /v1/slip/verify
{
"image_base64": "<base64 of the slip image>",
"expected_amount": "500.00"
}
➡️ HTTP 503 and nothing is charged. Ask the customer to retry later, or queue it for manual review
Gửi header Idempotency-Key (vd mã đơn): thử lại không bao giờ bị tính phí hai lần.
Mỗi biên lai chỉ VALID một lần cho mỗi key (lần thứ hai trả DUPLICATE).
Several sites receiving into the same account? Put their keys in the same group under “Duplicate-slip protection between keys” on the API Keys page. A slip that passed on one key then returns DUPLICATE on every key in the group (default: this key only).
Xác minh biên lai TrueMoney Wallet
truewallet_verify
Kiểm tra biên lai chuyển tiền TrueMoney Wallet là thật, đúng số tiền, chuyển vào số ví của bạn và chưa từng được dùng.
Cách hoạt động
Lưu ví nhận tiền một lần (PUT /v1/truewallet/profile, hoặc trên thẻ key ở cổng): số điện thoại ví hoặc e-Wallet ID, tên tiếng Thái/tiếng Anh và ảnh QR nhận tiền.
Hiển thị ảnh QR (qr_image_url) để khách thanh toán, rồi cho khách tải ảnh biên lai lên.
Gửi ảnh biên lai (image_base64) và số tiền dự kiến tới API. Số và tên lấy từ hồ sơ đã lưu (hoặc gửi wallet_number / ewallet_id trong yêu cầu).
Một biên lai qua được cả hai trang ⚠️ khách có thể nạp hai lần — hãy liên kết key
2 trang có tài khoản nhận khác nhau
Chỉ key này (mặc định)
Biên lai của trang này sang trang kia đã trả RECEIVER_MISMATCH ✅
2 trang thuộc 2 tài khoản tungkao khác nhau (chủ khác) nhưng cùng tài khoản nhận
Không thể liên kết key giữa các tài khoản tungkao
Một biên lai qua cả hai ⚠️ — hãy mua cả hai key từ một tài khoản tungkao và liên kết
Một trang dùng 2 key (vd. web + ứng dụng)
Cả hai key: cùng nhóm
Biên lai chỉ dùng được một lần dù gửi từ web hay ứng dụng ✅
DUPLICATE được phát hiện ngay từ mã tham chiếu trong QR. Cài ở thẻ “Chống dùng lại biên lai giữa các key” trên trang API Keys (key mới mặc định: chỉ key này).
📚 Ví dụ sử dụng
Ví dụ 1
Lưu ví nhận tiền một lần
Tình huống: Cửa hàng nhận tiền vào TrueMoney 081-234-5678 (Somchai) và có QR nhận tiền
Yêu cầu
PUT /v1/truewallet/profile
{
"receive_by": "wallet_number",
"wallet_number": "0812345678",
"name_en": "Somchai Jaidee",
"qr_image_base64": "<base64 of the QR image>"
}
Tình huống: Khách thanh toán qua e-Wallet ID 15 số; bạn không phải công khai số điện thoại
Yêu cầu
PUT /v1/truewallet/profile
{
"receive_by": "ewallet_id",
"ewallet_id": "140000812345678"
}
➡️ Biên lai chuyển vào số điện thoại trả RECEIVER_MISMATCH; chỉ chấp nhận e-Wallet ID
Ví dụ 4
Gửi người nhận trong yêu cầu (nhiều ví)
Tình huống: Bạn xoay vòng nhiều ví theo chi nhánh
Yêu cầu
POST /v1/truewallet/verify
{
"image_base64": "<base64 of the slip image>",
"expected_amount": "300.00",
"wallet_numbers": [
"0812345678",
"0898765432"
],
"wallet_name_en": "Somchai Jaidee"
}
➡️ Qua nếu biên lai chuyển vào một ví trong danh sách và tên khớp
Ví dụ 5
Nhà cung cấp chính lỗi, dự phòng tiếp quản
Tình huống: Dịch vụ xác minh chính lỗi khi khách đang gửi
Yêu cầu
POST /v1/truewallet/verify
{
"image_base64": "<base64 of the slip image>",
"expected_amount": "300.00"
}
➡️ Dự phòng xác minh ngay trong cùng yêu cầu. Gửi image_base64: dự phòng xác minh từ ảnh
Ví dụ 6
Trùng hoặc sai số tiền
Tình huống: Khách gửi lại biên lai hoặc chuyển thiếu
Phản hồi mẫu
{
"success": false,
"status": "DUPLICATE"
}
➡️ DUPLICATE = đã dùng · AMOUNT_MISMATCH = sai số tiền. Không cộng tín dụng trong cả hai trường hợp
Xác định người nhận bằng một trong hai hoặc cả hai: wallet_number (số điện thoại 10 số) hoặc ewallet_id (e-Wallet ID 15 số). Biên lai khớp một trong hai là qua.
Chọn cách nhận bằng receive_by: wallet_number (chỉ số), ewallet_id (chỉ e-Wallet ID) hoặc any (mặc định, một trong hai). Biên lai được kiểm tra theo định danh đã chọn.
Tên người nhận: name_th, name_en hoặc cả hai (wallet_name_th / wallet_name_en trong yêu cầu xác minh). Nếu đặt, biên lai phải khớp một tên; nếu không đặt, không kiểm tra tên.
Ảnh QR nhận tiền: JPG/PNG tối đa 1 MB, đọc được QR. Bạn nhận qr_image_url cho trang thanh toán; tải ảnh mới sẽ tạo liên kết mới.
wallet_number là số điện thoại 10 số của ví nhận. Gửi nhiều số bằng wallet_numbers (tối đa 10) hoặc lưu trên key ở cổng.
Phản hồi và trạng thái giống /v1/slip/verify. Mỗi biên lai chỉ VALID một lần cho mỗi key (lần thứ hai trả DUPLICATE).
Gửi header Idempotency-Key (vd mã đơn): thử lại không bao giờ bị tính phí hai lần.
🏦
Nạp tiền bằng biên lai
slip_deposit
Nạp tiền cho người dùng: kiểm tra biên lai, ghi nhận khoản nạp của người đó và báo site qua webhook.
Cách hoạt động
Đặt tài khoản nhận và URL webhook cho key trong cổng.
Gửi biên lai kèm customer_ref (ID người dùng của bạn).
Khi nhận webhook deposit.succeeded (kiểm tra chữ ký) hãy cộng tiền cho người dùng.
Mỗi webhook có X-Tungkao-Signature: t=…,v1=…. Kiểm tra trước khi tin dữ liệu (bí mật webhook hiện khi bạn đặt URL).
import crypto from "node:crypto";
// use the raw body only — never re-JSON.stringify it
function verify(rawBody, header, secret) {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header || "");
if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
const want = crypto.createHmac("sha256", secret).update(`${m[1]}.${rawBody}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(want), Buffer.from(m[2]));
}
Tình huống: A member tries to deposit again with the same slip
Phản hồi mẫu
{
"success": false,
"status": "DUPLICATE"
}
➡️ DUPLICATE; no new deposit is created
🔐
Sign-in for your website (Google, LINE, Facebook, Apple, TikTok, Discord, Telegram, X, Microsoft, GitHub + 14 more)
Add 'Sign in with …' to your site without registering with each provider. Get name, email, photo, a stable member id, and a member list with sign-in history. One service per provider: google_login, line_login, facebook_login, tiktok_login, discord_login, telegram_login, x_login, microsoft_login, github_login.
Cách hoạt động
Tạo key cho nhà cung cấp, rồi ở 'Thành viên đăng nhập' đặt tên site và redirect URI (https, khớp chính xác).
Nút đăng nhập đưa người dùng tới /oauth/authorize kèm client_id (ID key), redirect_uri và state (ngẫu nhiên mới, lưu trong session).
Người dùng quay về redirect_uri?code=…&state=… → kiểm tra state → máy chủ gọi POST /v1/login/token trong vòng 2 phút.
Dùng data.user (vd 7F3K9QX2-yourshopcom) làm ID thành viên — cùng một người luôn cùng một ID.
One site, 2 keys of the same provider (e.g. website + app, both Google)
Both keys: Combined (default)
The same person gets the same user ID in both ✅
One site, 2 keys of the same provider, counted as separate accounts
Both keys: Separate
The same person gets a different user ID on each key
2 sister sites sharing members
Both keys: Group A
A member has the same user ID on both sites ✅
2 unrelated sites that must not link members
Both keys: Separate
Different user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)
Any setting
Always different user IDs — they are different provider accounts
A key that already has sign-ins needs a different group
Not allowed (locked 🔒)
Create a new key in the wanted group, so member IDs on your site never change
Set it on the “Sign-in user IDs between keys” card on the API Keys page before go-live (new keys default: Combined). Several keys may use the same domain.
Ví dụ đầy đủ (nút + callback + đổi code)
// npm i express express-session
import express from "express";
import session from "express-session";
import crypto from "node:crypto";
const KEY = process.env.TUNGKAO_KEY; // API key (tk_live_…) server-side only
const CLIENT_ID = process.env.TUNGKAO_CLIENT_ID; // the key id (shown in the portal), not a secret
const REDIRECT = "https://yourshop.com/auth/callback"; // must match the registered URL exactly
const app = express();
app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, cookie: { secure: true, sameSite: "lax" } }));
// 1) your "Sign in" button links here
app.get("/auth/login", (req, res) => {
req.session.state = crypto.randomBytes(24).toString("base64url");
const u = new URL("https://api.tungkao.com/oauth/authorize");
u.search = new URLSearchParams({ client_id: CLIENT_ID, redirect_uri: REDIRECT, state: req.session.state });
res.redirect(u);
});
// 2) the user comes back with a code
app.get("/auth/callback", async (req, res) => {
if (!req.query.state || req.query.state !== req.session.state) return res.status(400).send("state mismatch");
delete req.session.state;
if (req.query.error) return res.redirect("/login?cancelled=1");
// 3) exchange the code for the user (within 2 minutes)
const r = await fetch("https://api.tungkao.com/v1/login/token", {
method: "POST",
headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ code: req.query.code, redirect_uri: REDIRECT }),
});
const j = await r.json();
if (!j.success) return res.status(400).send(j.error.message);
req.session.user = j.data; // j.data.user = permanent member id, e.g. 7F3K9QX2-yourshopcom
res.redirect("/");
});
app.listen(3000);
<?php
// login.php — your "Sign in" button links to this file
session_start();
$CLIENT_ID = getenv("TUNGKAO_CLIENT_ID");
$REDIRECT = "https://yourshop.com/callback.php";
$_SESSION["state"] = bin2hex(random_bytes(24));
header("Location: https://api.tungkao.com/oauth/authorize?" . http_build_query([
"client_id" => $CLIENT_ID, "redirect_uri" => $REDIRECT, "state" => $_SESSION["state"],
]));
<?php
// callback.php — the user comes back here
session_start();
$REDIRECT = "https://yourshop.com/callback.php";
if (empty($_GET["state"]) || !hash_equals($_SESSION["state"] ?? "", $_GET["state"])) { http_response_code(400); exit("state mismatch"); }
unset($_SESSION["state"]);
if (!empty($_GET["error"])) { header("Location: /login.php?cancelled=1"); exit; }
$ch = curl_init("https://api.tungkao.com/v1/login/token");
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("TUNGKAO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(["code" => $_GET["code"], "redirect_uri" => $REDIRECT]),
]);
$j = json_decode(curl_exec($ch), true);
if (!$j["success"]) { http_response_code(400); exit($j["error"]["message"]); }
$_SESSION["user"] = $j["data"]; // $j["data"]["user"] = permanent member id
header("Location: /");
# pip install flask requests
import os, secrets, requests
from urllib.parse import urlencode
from flask import Flask, session, request, redirect, abort
app = Flask(__name__)
app.secret_key = os.environ["SESSION_SECRET"]
KEY = os.environ["TUNGKAO_KEY"]
CLIENT_ID = os.environ["TUNGKAO_CLIENT_ID"]
REDIRECT = "https://yourshop.com/auth/callback"
@app.get("/auth/login")
def login():
session["state"] = secrets.token_urlsafe(24)
return redirect("https://api.tungkao.com/oauth/authorize?" + urlencode({"client_id": CLIENT_ID, "redirect_uri": REDIRECT, "state": session["state"]}))
@app.get("/auth/callback")
def callback():
if not request.args.get("state") or not secrets.compare_digest(request.args["state"], session.pop("state", "")):
abort(400)
if request.args.get("error"):
return redirect("/login?cancelled=1")
r = requests.post("https://api.tungkao.com/v1/login/token", headers={"Authorization": f"Bearer {KEY}"},
json={"code": request.args["code"], "redirect_uri": REDIRECT}, timeout=30).json()
if not r["success"]:
abort(400, r["error"]["message"])
session["user"] = r["data"] # r["data"]["user"] = permanent member id
return redirect("/")
Nhà cung cấp
Dịch vụ
Bạn nhận được
Google
google_login
tên, email đã xác minh, ảnh
LINE
line_login
tên, ảnh, email nếu người dùng đồng ý
Facebook
facebook_login
tên, ảnh, email
TikTok
tiktok_login
tên hiển thị, ảnh đại diện (không email)
Discord
discord_login
tên, ảnh đại diện, email
Telegram
telegram_login
name, username, photo
X (Twitter)
x_login
name, username, photo
Microsoft
microsoft_login
name, email (Hotmail/Outlook)
GitHub
github_login
name, email, avatar
Apple
apple_login
permanent member ID (no name or email in this mode)
Steam
steam_login
name, avatar and SteamID (no email)
Twitch
twitch_login
name, email, avatar
LinkedIn
linkedin_login
name, email, photo
Kakao
kakao_login
name, photo (email once Kakao approves it)
NAVER
naver_login
name, email, photo
Zalo
zalo_login
name, photo (no email)
Spotify
spotify_login
name, email, photo
Reddit
reddit_login
username, avatar (no email)
GitLab
gitlab_login
name, email, avatar
Roblox
roblox_login
name, avatar (no email)
Epic Games
epicgames_login
display name (no email)
Yahoo
yahoo_login
name, email, photo
Slack
slack_login
name, email, photo
Amazon
amazon_login
name, email
📚 Ví dụ sử dụng
Ví dụ 1
A “Sign in with Google” button on your site
Tình huống: A visitor taps Sign in with Google on your site
Yêu cầu
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz
➡️ The user signs in with Google and returns to redirect_uri with a code and the same state
Ví dụ 2
Exchange the code for the user (server side)
Tình huống: Your server receives the code on the callback page (exchange within 2 minutes)
Yêu cầu
POST /v1/login/token
{
"code": "<code from the callback>",
"redirect_uri": "https://yourshop.com/auth/callback"
}
➡️ Same user every time → look up the member and sign them in
Ví dụ 4
One site, two Google keys (website + app)
Tình huống: Separate keys for website and app, same members
➡️ Keep both keys “Combined” (default) before go-live → same user for the same person. Choose “Separate” to keep them apart
Ví dụ 5
List members who signed in
Tình huống: You want to browse or search members of this key
Yêu cầu
GET /v1/login/users?q=somchai&limit=50
➡️ Returns members with last sign-in time and count
Ví dụ 6
The user cancels during sign-in
Tình huống: The user cancels on the Google screen
➡️ Returns to redirect_uri with error instead of code; show a retry button
User IDs between keys: new keys default to “Combined (whole account)”, so the same person signing in through keys of the same provider in one account gets the same ID. Change it to group A–E or “Separate” on the API Keys page before the first sign-in; after that the group is locked so member IDs never change.
Tính phí mỗi lần đăng nhập thành công và một lần cho mỗi thành viên mới — xem giá hiện tại trên thẻ dịch vụ.
Key chế độ test cho phép redirect http://localhost và miễn phí.
Không bao giờ đặt API key trong link hay trang — /oauth/authorize chỉ cần client_id (ID key) công khai.
✈️
Thông báo Telegram
telegram_notify
Nhắn tin Telegram cho người dùng qua bot của TUNGKAO — không cần bot riêng. Vd tiền về, trạng thái đơn, OTP.
Cách hoạt động
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.
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).
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).
Check the connection: GET /v1/telegram/recipients (status = active) — use it to switch your button to “Connected ✓”.
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.
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.
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/send
{
"refs": [
"member-1001",
"member-1002",
"member-1003"
],
"text": "New promotion today"
}
➡️ Sent to each member; check results with GET /v1/telegram/messages
Ví dụ 5
A member stops notifications
Tình huống: The member asks to disconnect
Yêu cầu
DELETE /v1/telegram/recipients/member-1001
➡️ The link is removed; no more messages are sent
Chỉ tính phí tin đã gửi tới — lỗi (vd người dùng chặn bot) được hoàn và người nhận đó bị tạm dừng.
🔔
Thông báo Discord
discord_notify
Gửi tin vào kênh Discord của bạn hoặc khách — vd báo đơn mới cho đội.
Cách hoạt động
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).
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.
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.
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.
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.
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.
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/email/send
{
"to": [
"[email protected]"
],
"subject": "Order #1001 confirmed",
"html": "<h1>Thanks for your order</h1>",
"text": "Thanks for your order",
"from_name": "My Shop",
"reply_to": "[email protected]"
}
➡️ Always send html and text; replies go to reply_to
Ví dụ 2
Send an email OTP
Tình huống: A new sign-up must confirm their email
Yêu cầu
POST /v1/email/otp/send
{
"to": "[email protected]",
"brand": "My Shop",
"lang": "th",
"length": 6,
"ttl_seconds": 300
}
Tình huống: A customer says the email never arrived
Yêu cầu
GET /v1/email/messages
➡️ Check the delivery status of each email
Thư được gửi từ địa chỉ của TUNGKAO; tên người gửi (from_name) và reply_to là của bạn.
Nếu mọi nhà cung cấp đều lỗi, credit được hoàn tự động · tệp đính kèm qua SMTP không được chuyển tiếp.
₿
Thanh toán crypto (sắp ra mắt)
crypto
Mỗi người dùng có địa chỉ BTC / USDT / USDC riêng (TRON, Ethereum, BNB Chain, Polygon, Arbitrum, Base, Optimism, Avalanche) và báo bạn qua webhook — sắp ra mắt.
➡️ Always check the address matches the network; wrong-network transfers can't be recovered
💸 Withdrawal fees: funds received through the API pay 3.5% per withdrawal; wallets you create yourself in the merchant portal pay 2.5%. Taken from the withdrawn coin, not credits; deposits are free (live rate: withdraw_fee_percent in GET /v1/crypto/assets).
🚦 Trạng thái hệ thống (GET /status)
Kiểm tra API có bình thường không bất cứ lúc nào — không cần key
GET https://api.tungkao.com/status
🟢 ok = bình thường
🟠 busy = lưu lượng cao
🔴 slow = hơi chậm
Đo từ yêu cầu thật trong 5 phút gần nhất, theo từng dịch vụ (services[]). Xác minh/nạp bằng biên lai được đo trên mọi nhà cung cấp dự phòng, trạng thái từng tuyến trong routes[]
Không cần API key, gọi được từ trình duyệt (mở CORS), cache 15 giây — nên kiểm tra tối đa 1 lần/phút
Khi busy/slow, tăng timeout lên 15–20 giây và thử lại với cùng Idempotency-Key — không bị tính phí hai lần
API /v1 được khóa vĩnh viễn: không xóa, không đổi tên, không đổi kiểu — chỉ thêm trường hoặc endpoint mới. Kiểm thử hợp đồng tự động chặn mọi lần triển khai làm hỏng mã cũ.
Khi nhà cung cấp (ngân hàng, LINE, Google, Facebook, TikTok, Discord, Telegram, blockchain) thay đổi, chúng tôi xử lý ở máy chủ — mã của bạn giữ nguyên. Kiểm tra biên lai tự chuyển dự phòng giữa 3 nhà cung cấp.
Viết mã bền vững: bỏ qua trường lạ, phân nhánh theo error.code (không theo câu chữ), coi status mới chưa biết là “chưa đạt/đang chờ”.
Nếu có gì phải ngừng, chúng tôi báo trước ít nhất 12 tháng qua header Deprecation / Sunset trong mọi phản hồi, email và webhook — cách cũ vẫn chạy tới ngày đó.
Mọi phản hồi có header X-Tungkao-Api-Version ghi phiên bản và ngày sửa đổi mới nhất. Toàn bộ lịch sử: /changelog.json
🏷️ Yêu cầu ghi nguồn TUNGKAO
Mọi trang dùng dịch vụ TUNGKAO phải hiển thị rõ “Powered by TUNGKAO” hoặc “Secured by TUNGKAO” và liên kết tới https://tungkao.com
Đặt gần chức năng; không ẩn, không trùng màu nền, không quá nhỏ
Nút từ trang “Nút đăng nhập” đã tự kèm ghi nguồn; trang đăng nhập của TUNGKAO cũng tự hiển thị
Ví dụ: <a href="https://tungkao.com" target="_blank" rel="noopener">Powered by TUNGKAO</a>
Muốn bỏ ghi nguồn (white-label) cần được phê duyệt trước