TUNGKAO API docs

Integrate with TUNGKAO

One API style for every service — Base URL: https://api.tungkao.com

🕒 Latest API updates by channel

Whole platform last updated: Thailand time (UTC+07:00) — 📘 The TrueMoney Wallet docs page is now fully translated into all 10 languages (steps, examples, case table, notes)

✅ Your existing code keeps working · /changelog.json (Machine-readable)

Paste it into the AI that maintains your site's code (ChatGPT / Claude / Gemini); it checks and changes only what is needed
🧾Bank slip verification Thailand time (UTC+07:00)Duplicate-slip protection between keys is now configurable: this key only / group A–E / whole account — for several sites that receive into the same accountTrueMoney Wallet slip verification Thailand time (UTC+07:00)📘 The TrueMoney Wallet docs page is now fully translated into all 10 languages (steps, examples, case table, notes)🏦Slip deposits Thailand time (UTC+07:00)Launched slip deposits with webhooks₿Crypto payments Thailand time (UTC+07:00)Added Ethereum, Polygon, Arbitrum, Base, Optimism, Avalanche networks and USDCTelegram notifications Thailand time (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)Discord notifications Thailand time (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)📧Email sending + OTP + SMTP Thailand time (UTC+07:00)Email service launched: API + SMTP (smtp.tungkao.com) + email OTPSign in with Google Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with LINE Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Facebook Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with TikTok Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Discord Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Telegram Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with X (Twitter) Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Microsoft Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with GitHub Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Apple Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Steam Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Twitch Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with LinkedIn Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Kakao Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with NAVER Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Zalo Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Spotify Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Reddit Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with GitLab Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Roblox Thailand time (UTC+07:00)🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.Sign in with Epic Games Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Yahoo Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Slack Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their groupSign in with Amazon Thailand time (UTC+07:00)Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their group
🚀

Getting started

Every service works the same way: create an API key in the merchant portal (one key per service) and send it in the Authorization header of every request.

How it works

  1. Sign in at app.tungkao.com with Gmail and top up credits (1 THB = 100 credits).
  2. API keys → pick a service card → choose the key lifetime → Create → copy the key (shown once).
  3. Keep the key on your server (env var TUNGKAO_KEY). Never put it in web pages or mobile apps.
  4. Start with a test key (tk_test_…) — no credits charged — then switch to live.
GET/v1/account — Test your key: credits left
curl -X GET https://api.tungkao.com/v1/account \
  -H "Authorization: Bearer $TUNGKAO_KEY"

Signing requests (when enabled)

import crypto from "node:crypto";
async function tungkao(method, path, body) {
  const raw = body ? JSON.stringify(body) : "";
  const ts = Math.floor(Date.now() / 1000).toString();
  const hash = crypto.createHash("sha256").update(raw).digest("hex");
  const sig = crypto.createHmac("sha256", process.env.TUNGKAO_SIGNING_SECRET).update(`${ts}.${method}.${path}.${hash}`).digest("hex");
  const r = await fetch("https://api.tungkao.com" + path, { method, body: raw || undefined, headers: {
    Authorization: `Bearer ${process.env.TUNGKAO_KEY}`, "Content-Type": "application/json",
    "X-Tungkao-Timestamp": ts, "X-Tungkao-Signature": sig } });
  return r.json();
}
console.log(await tungkao("GET", "/v1/account"));
  • Every response is JSON with success and request_id. Errors carry error.code (e.g. KEY_EXPIRED, INSUFFICIENT_CREDITS) — see /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.
  • Keys expire as chosen (1–24 months or never). We warn 30/7/1 days before via the api_key.expiring webhook. Renew in the portal — the key string stays the same.
  • Domain verification: each live key is bound to one website. API keys → 'Domain verification' → enter your domain, upload tungkao-verify-….html to https://yourdomain/ (or add DNS TXT _tungkao-verify.yourdomain) and press Verify. Unverified keys get DOMAIN_NOT_VERIFIED; a verified domain can't change and no other account can use it.
  • Leaked secret? Press 'Rotate now' — unlimited, the old key stops at once. A key only works for its own service (WRONG_PRODUCT otherwise).
  • Advanced (optional): turn on 'Signed requests' on a key to get a tksign_… secret; every request then needs X-Tungkao-Timestamp and X-Tungkao-Signature = HMAC-SHA256(secret, ts.METHOD.path.sha256(body)). A leaked key alone becomes useless.
  • 🧪 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.
  • Send Accept-Language (th, en, lo, my, zh-CN, ko, ja, vi, km, id) to choose the message language.
🧾

Bank slip verification

slip_verify

Checks a slip is genuine, the amount matches, it was paid to you and hasn't been used — for shops where customers attach a slip.

How it works

  1. Customer uploads the slip; your site reads its QR text (starts with 0041…).
  2. Send qr_payload, the expected amount and your receiving account to the API.
  3. Accept the order only when status is VALID.
POST/v1/slip/verify
curl -X POST https://api.tungkao.com/v1/slip/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"qr_payload":"0041000600000101030040220014…","expected_amount":"500.00","receivers":[{"bank":"KBANK","account_number":"1234567890"}]}'

📖 Summary: using keys on several sites

CaseKey setting (API Keys page)Result
2 sites (aaa.com, bbb.com) receive into the same accountBoth keys: Group A (or Whole account)A slip that passed on aaa.com returns DUPLICATE on bbb.com — usable on one site only ✅
2 sites share an account but the keys stay separate (default)Both keys: This key onlyOne slip passes on both sites ⚠️ customers could top up twice — link the keys
2 sites with different receiving accountsThis key only (default)A slip for one site already returns RECEIVER_MISMATCH on the other ✅
2 sites on different tungkao accounts (different owners) but the same receiving accountKeys can't be linked across tungkao accountsOne slip passes on both ⚠️ — buy both keys from one tungkao account and link them
One site using 2 keys (e.g. website + app)Both keys: the same groupA slip is usable once whether sent from the website or the app ✅

DUPLICATE is detected from the reference in the QR right away. Set it on the “Duplicate-slip protection between keys” card on the API Keys page (new keys default: this key only).

📚 Usage examples

Example 1

Customer tops up with a matching slip (passes)

Situation: A customer transfers 500 THB to your account and uploads the slip on your top-up page

Request
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00"
}
Sample response
{
  "success": true,
  "status": "VALID",
  "data": {
    "trans_ref": "2025111612345678",
    "amount": "500.00",
    "currency": "THB"
  },
  "billing": {
    "credits_charged": 250
  }
}

➡️ VALID → credit the customer now; the slip is marked as used

Example 2

Send the QR text instead of the image (faster)

Situation: Your app reads the QR on the slip itself and sends only the QR text

Request
POST /v1/slip/verify
{
  "qr_payload": "0041000600000101030040220014242082547BPM04988…",
  "expected_amount": "500.00"
}

➡️ Same result as sending the image, smaller and faster. If you have the image, send it: some backup providers verify from the image

Example 3

The customer sends the same slip again

Situation: The customer attaches the same 500 THB slip again to top up twice

Request
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00"
}
Sample response
{
  "success": false,
  "status": "DUPLICATE",
  "message": "This slip has already been used"
}

➡️ DUPLICATE → do not credit; tell the customer the slip was already used

Example 4

Wrong amount or wrong account

Situation: The customer paid 300 THB for a 500 THB order, or paid another account

Request
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00",
  "receivers": [
    {
      "bank": "KBANK",
      "account_number": "123-4-56789-0"
    }
  ]
}
Sample response
{
  "success": false,
  "status": "AMOUNT_MISMATCH"
}

➡️ AMOUNT_MISMATCH = wrong amount · RECEIVER_MISMATCH = other account. The slip is not marked as used, so the customer can retry with the right one

Example 5

Slip is too old

Situation: You only accept slips paid within the last 30 minutes

Request
POST /v1/slip/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "500.00",
  "max_age_minutes": 30
}
Sample response
{
  "success": false,
  "status": "DATE_MISMATCH"
}

➡️ DATE_MISMATCH when the slip is older than allowed

Example 6

Two sites, one receiving account

Situation: aaa.com and bbb.com use different keys but receive into the same account

➡️ Put both keys in one group on the “Duplicate-slip protection between keys” card → a slip that passed on aaa.com returns DUPLICATE on bbb.com

Example 7

Every verifier is down

Situation: All upstream verifiers fail at once (rare; backups are tried first)

Sample response
{
  "success": false,
  "status": "SERVICE_UNAVAILABLE"
}

➡️ HTTP 503 and nothing is charged. Ask the customer to retry later, or queue it for manual review

  • Send an Idempotency-Key header (e.g. your order id): retries are never charged twice.
  • A slip is VALID once per key (the second time returns 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).

TrueMoney Wallet slip verification

truewallet_verify

Checks a TrueMoney Wallet transfer slip is genuine, the amount matches, it was paid to your e-wallet number and has not been used before.

How it works

  1. Save your receiving wallet once (PUT /v1/truewallet/profile, or on the key card in the portal): wallet mobile number or e-Wallet ID, Thai/English name and the receiving QR image.
  2. Show the QR image (qr_image_url) for your customer to pay, then let them upload the slip image.
  3. Send the slip image (image_base64) and the expected amount to the API. The number and name come from the saved profile (or send wallet_number / ewallet_id in the request).
  4. Accept the order only when status is VALID.
PUT/v1/truewallet/profile
curl -X PUT https://api.tungkao.com/v1/truewallet/profile \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"wallet_number":"0812345678","ewallet_id":"140000812345678","name_en":"Somchai Jaidee","qr_image_base64":"<base64 QR image>"}'
GET/v1/truewallet/profile
curl -X GET https://api.tungkao.com/v1/truewallet/profile \
  -H "Authorization: Bearer $TUNGKAO_KEY"
POST/v1/truewallet/verify
curl -X POST https://api.tungkao.com/v1/truewallet/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_base64":"<base64 slip image>","expected_amount":"500.00"}'

📖 Summary: using keys on several sites

CaseKey setting (API Keys page)Result
2 sites (aaa.com, bbb.com) receive into the same accountBoth keys: Group A (or Whole account)A slip that passed on aaa.com returns DUPLICATE on bbb.com — usable on one site only ✅
2 sites share an account but the keys stay separate (default)Both keys: This key onlyOne slip passes on both sites ⚠️ customers could top up twice — link the keys
2 sites with different receiving accountsThis key only (default)A slip for one site already returns RECEIVER_MISMATCH on the other ✅
2 sites on different tungkao accounts (different owners) but the same receiving accountKeys can't be linked across tungkao accountsOne slip passes on both ⚠️ — buy both keys from one tungkao account and link them
One site using 2 keys (e.g. website + app)Both keys: the same groupA slip is usable once whether sent from the website or the app ✅

DUPLICATE is detected from the reference in the QR right away. Set it on the “Duplicate-slip protection between keys” card on the API Keys page (new keys default: this key only).

📚 Usage examples

Example 1

Save your receiving wallet once

Situation: Your shop receives into TrueMoney 081-234-5678 (Somchai) and has a receiving QR

Request
PUT /v1/truewallet/profile
{
  "receive_by": "wallet_number",
  "wallet_number": "0812345678",
  "name_en": "Somchai Jaidee",
  "qr_image_base64": "<base64 of the QR image>"
}
Sample response
{
  "success": true,
  "data": {
    "receive_by": "wallet_number",
    "wallet_number": "0812345678",
    "qr_image_url": "https://api.tungkao.com/v1/truewallet/qr/…"
  }
}

➡️ Show qr_image_url on your payment page for customers to scan

Example 2

Verify using the saved wallet

Situation: A customer pays 300 THB to your TrueMoney wallet and attaches the slip

Request
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00"
}
Sample response
{
  "success": true,
  "status": "VALID",
  "data": {
    "amount": "300.00",
    "currency": "THB"
  }
}

➡️ No need to resend the number; the key's saved wallet is used

Example 3

Receive with the e-Wallet ID only

Situation: Customers pay via the 15-digit e-Wallet ID; you don't share your phone number

Request
PUT /v1/truewallet/profile
{
  "receive_by": "ewallet_id",
  "ewallet_id": "140000812345678"
}

➡️ Slips paid to the phone number return RECEIVER_MISMATCH; only the e-Wallet ID is accepted

Example 4

Send the receiver in the request (several wallets)

Situation: You rotate between several wallets per branch

Request
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00",
  "wallet_numbers": [
    "0812345678",
    "0898765432"
  ],
  "wallet_name_en": "Somchai Jaidee"
}

➡️ Passes if the slip went to any listed wallet and the name matches

Example 5

Primary provider down, backup takes over

Situation: The primary verifier fails while the customer submits

Request
POST /v1/truewallet/verify
{
  "image_base64": "<base64 of the slip image>",
  "expected_amount": "300.00"
}

➡️ The backup verifies within the same request. Send image_base64: the backup verifies from the image

Example 6

Duplicate or wrong amount

Situation: The customer resubmits a slip or underpays

Sample response
{
  "success": false,
  "status": "DUPLICATE"
}

➡️ DUPLICATE = already used · AMOUNT_MISMATCH = wrong amount. Credit nothing in both cases

  • Identify the receiver either way, or both: wallet_number (10-digit mobile number) or ewallet_id (15-digit e-Wallet ID). A slip matching either one passes.
  • Choose what you receive with via receive_by: wallet_number (number only), ewallet_id (e-Wallet ID only) or any (default, either one). Slips are checked against the chosen identifier.
  • Receiver name: name_th, name_en or both (wallet_name_th / wallet_name_en in a verify request). If set, the slip must match one of them; if not set, the name is not checked.
  • Receiving QR image: JPG/PNG up to 1 MB with a readable QR. You get qr_image_url for your payment page; uploading a new image issues a new link.
  • wallet_number is the 10-digit mobile number of the receiving wallet. Send several with wallet_numbers (max 10), or save them on the key in the portal.
  • Responses and statuses are identical to /v1/slip/verify. A slip is VALID once per key (the second time returns DUPLICATE).
  • Send an Idempotency-Key header (e.g. your order id): retries are never charged twice.
🏦

Slip deposits

slip_deposit

Top-ups for your users: verifies the slip, records the deposit for that user and notifies your site by webhook.

How it works

  1. Set receiving accounts and a webhook URL on the key in the portal.
  2. Send the slip with customer_ref (your user id).
  3. On the deposit.succeeded webhook (verify the signature) credit the user.
POST/v1/deposits/slip
curl -X POST https://api.tungkao.com/v1/deposits/slip \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"qr_payload":"0041000600000101030040220014…","customer_ref":"member-1001","expected_amount":"300.00"}'
GET/v1/deposits/dep_xxx
curl -X GET https://api.tungkao.com/v1/deposits/dep_xxx \
  -H "Authorization: Bearer $TUNGKAO_KEY"

Verify the webhook signature

Every webhook carries X-Tungkao-Signature: t=…,v1=…. Verify it before trusting the data (the webhook secret is shown when you set the 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]));
}

📚 Usage examples

Example 1

Credit a member's deposit

Situation: Member member-1001 deposits 300 THB and attaches the slip

Request
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "expected_amount": "300.00"
}
Sample response
{
  "success": true,
  "status": "VALID",
  "data": {
    "deposit_id": "dep_8f2c…",
    "customer_ref": "member-1001",
    "amount": "300.00"
  }
}

➡️ Store deposit_id with the order and credit the member

Example 2

Attach your own data to the deposit

Situation: You want to know which promotion the deposit came from

Request
POST /v1/deposits/slip
{
  "image_base64": "<base64 of the slip image>",
  "customer_ref": "member-1001",
  "metadata": {
    "promo": "NEWYEAR",
    "channel": "app"
  }
}

➡️ metadata comes back in the webhook and when you fetch the deposit

Example 3

Receive the result by webhook

Situation: With a webhook URL on the key, the result is pushed to your site

➡️ Verify the webhook signature before crediting and use deposit_id to avoid double credit

Example 4

Check a deposit later

Situation: Your site missed the webhook or wants to re-check

Request
GET /v1/deposits/dep_8f2c…
Sample response
{
  "success": true,
  "data": {
    "deposit_id": "dep_8f2c…",
    "status": "succeeded"
  }
}

➡️ succeeded = credit · failed = rejected · pending = wait

Example 5

Member resubmits the same slip

Situation: A member tries to deposit again with the same slip

Sample response
{
  "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.

How it works

  1. Create a key for the provider, then on 'Sign-in members' set your site name and redirect URI (https, exact match).
  2. Your sign-in button sends the user to /oauth/authorize with client_id (the key id), redirect_uri and state (fresh random, kept in the session).
  3. The user returns to redirect_uri?code=…&state=… → check state → your server calls POST /v1/login/token within 2 minutes.
  4. Use data.user (e.g. 7F3K9QX2-yourshopcom) as the member id — the same person always gets the same id.
POST/v1/login/token
curl -X POST https://api.tungkao.com/v1/login/token \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"from the redirect","redirect_uri":"https://yourshop.com/auth/callback"}'
GET/v1/login/users?limit=50
curl -X GET https://api.tungkao.com/v1/login/users?limit=50 \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📖 Summary: using sign-in keys on several sites

CaseKey setting (API Keys page)Result
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 accountsBoth keys: SeparateThe same person gets a different user ID on each key
2 sister sites sharing membersBoth keys: Group AA member has the same user ID on both sites ✅
2 unrelated sites that must not link membersBoth keys: SeparateDifferent user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)Any settingAlways different user IDs — they are different provider accounts
A key that already has sign-ins needs a different groupNot 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.

Complete example (button + callback + code exchange)

// 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);
ProviderServiceYou get
Googlegoogle_loginname, verified email, photo
LINEline_loginname, photo, email if the user agrees
Facebookfacebook_loginname, photo, email
TikToktiktok_logindisplay name, avatar (no email)
Discorddiscord_loginname, avatar, email
Telegramtelegram_loginname, username, photo
X (Twitter)x_loginname, username, photo
Microsoftmicrosoft_loginname, email (Hotmail/Outlook)
GitHubgithub_loginname, email, avatar
Appleapple_loginpermanent member ID (no name or email in this mode)
Steamsteam_loginname, avatar and SteamID (no email)
Twitchtwitch_loginname, email, avatar
LinkedInlinkedin_loginname, email, photo
Kakaokakao_loginname, photo (email once Kakao approves it)
NAVERnaver_loginname, email, photo
Zalozalo_loginname, photo (no email)
Spotifyspotify_loginname, email, photo
Redditreddit_loginusername, avatar (no email)
GitLabgitlab_loginname, email, avatar
Robloxroblox_loginname, avatar (no email)
Epic Gamesepicgames_logindisplay name (no email)
Yahooyahoo_loginname, email, photo
Slackslack_loginname, email, photo
Amazonamazon_loginname, email

📚 Usage examples

Example 1

A “Sign in with Google” button on your site

Situation: A visitor taps Sign in with Google on your site

Request
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

Example 2

Exchange the code for the user (server side)

Situation: Your server receives the code on the callback page (exchange within 2 minutes)

Request
POST /v1/login/token
{
  "code": "<code from the callback>",
  "redirect_uri": "https://yourshop.com/auth/callback"
}
Sample response
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "provider": "google",
    "name": "Somchai",
    "is_new_user": true
  }
}

➡️ Use user as the member id in your database (stable per person)

Example 3

A returning user signs in

Situation: The same person signs in with Google again

Sample response
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "is_new_user": false,
    "login_count": 5
  }
}

➡️ Same user every time → look up the member and sign them in

Example 4

One site, two Google keys (website + app)

Situation: 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

Example 5

List members who signed in

Situation: You want to browse or search members of this key

Request
GET /v1/login/users?q=somchai&limit=50

➡️ Returns members with last sign-in time and count

Example 6

The user cancels during sign-in

Situation: 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.
  • Credits are charged on each successful sign-in plus once per new member — see current prices on the service card.
  • Test-mode keys allow http://localhost redirect URIs and are free.
  • Never put the API key in links or pages — /oauth/authorize only needs client_id (the key id), which is public.
✈️

Telegram notifications

telegram_notify

Message your users on Telegram through TUNGKAO's bot — no bot of your own. E.g. payment received, order status, OTP.

How it works

  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"

📚 Usage examples

Example 1

Let a member connect Telegram

Situation: Member member-1001 wants notifications on Telegram

Request
POST /v1/telegram/link
{
  "ref": "member-1001"
}
Sample response
{
  "success": true,
  "data": {
    "url": "https://t.me/…?start=…"
  }
}

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

Example 2

Notify a payment

Situation: 500 THB arrived and you want to notify the member

Request
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

Example 3

Message with a link button

Situation: You want a button to open the order

Request
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

Example 4

Notify several members at once

Situation: Announce a promotion to three members

Request
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

Example 5

A member stops notifications

Situation: The member asks to disconnect

Request
DELETE /v1/telegram/recipients/member-1001

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

  • Only delivered messages are charged — failures (e.g. the user blocked the bot) are refunded and that recipient is paused.
🔔

Discord notifications

discord_notify

Post messages into your or your customers' Discord channels — e.g. new orders for your team.

How it works

  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"}'

📚 Usage examples

Example 1

Register a Discord channel

Situation: You want new orders posted in #orders

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

➡️ Name it once with ref and use it forever

Example 2

Post a new order

Situation: Order #1001 for 590 THB comes in

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

➡️ The message appears in the channel right away

Example 3

Custom sender name

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

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

➡️ The message shows Shop Bot as the sender

Example 4

Post to several channels

Situation: Notify both the admin and the stock channels

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

➡️ Posted to every listed channel

Example 5

Check sending history

Situation: You want to see which messages failed

Request
GET /v1/discord/messages

➡️ Returns each message with its status

📧

Email sending + OTP + SMTP

email

Send email from your site through the API or SMTP (WordPress works), plus email OTP codes with verification — we fail over between email providers automatically.

How it works

  1. Create an email key (test keys can only send to your own address, 50 per day).
  2. SMTP: host smtp.tungkao.com, port 587 (STARTTLS) or 465 (SSL), any username, password = your API key.
  3. API: send an email, or request an OTP and verify it with the returned otp_id (5 attempts, single use).
POST/v1/email/send
curl -X POST https://api.tungkao.com/v1/email/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"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]"}'
POST/v1/email/otp/send
curl -X POST https://api.tungkao.com/v1/email/otp/send \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"[email protected]","brand":"My Shop","lang":"th","length":6,"ttl_seconds":300}'
POST/v1/email/otp/verify
curl -X POST https://api.tungkao.com/v1/email/otp/verify \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"otp_id":"8f6c2a1e-…","code":"123456"}'

📚 Usage examples

Example 1

Order confirmation email

Situation: A customer completes an order

Request
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

Example 2

Send an email OTP

Situation: A new sign-up must confirm their email

Request
POST /v1/email/otp/send
{
  "to": "[email protected]",
  "brand": "My Shop",
  "lang": "th",
  "length": 6,
  "ttl_seconds": 300
}
Sample response
{
  "success": true,
  "data": {
    "otp_id": "8f6c2a1e-…"
  }
}

➡️ Keep otp_id; the code expires in 5 minutes

Example 3

Check the OTP

Situation: The user types the 6-digit code

Request
POST /v1/email/otp/verify
{
  "otp_id": "8f6c2a1e-…",
  "code": "123456"
}

➡️ Correct = email confirmed · too many wrong tries = code locked, send a new one

Example 4

Send to several people

Situation: Tell three staff about a large order

Request
POST /v1/email/send
{
  "to": [
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ],
  "subject": "Large order #1002",
  "text": "Order #1002: 25,000 THB"
}

➡️ Everyone listed receives the email

Example 5

Review sent emails

Situation: A customer says the email never arrived

Request
GET /v1/email/messages

➡️ Check the delivery status of each email

  • Mail is sent from TUNGKAO's address; the sender name (from_name) and reply_to are yours.
  • If every provider fails, credits are refunded automatically · SMTP attachments are not forwarded.
₿

Crypto payments (coming soon)

crypto

Gives each user their own BTC / USDT / USDC address (TRON, Ethereum, BNB Chain, Polygon, Arbitrum, Base, Optimism, Avalanche) and notifies you by webhook — launching soon.

How it works

  1. Request an address for a user
  2. The user sends funds
  3. Credit them on crypto.deposit.confirmed
POST/v1/crypto/addresses
curl -X POST https://api.tungkao.com/v1/crypto/addresses \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"asset":"USDT-TRC20","customer_ref":"member-1001"}'

📚 Usage examples

Example 1

Get a deposit address for a customer

Situation: member-1001 will pay in USDT on TRC20

Request
POST /v1/crypto/addresses
{
  "asset": "USDT-TRC20",
  "customer_ref": "member-1001"
}

➡️ You get a per-customer address to show as a QR

Example 2

List supported coins and networks

Situation: You want minimums and confirmations per coin

Request
GET /v1/crypto/assets

➡️ Returns min_deposit and confirmations_required per asset

Example 3

Check incoming deposits

Situation: Waiting for the customer's payment

Request
GET /v1/crypto/deposits
Sample response
{
  "success": true,
  "data": [
    {
      "asset": "USDT-TRC20",
      "customer_ref": "member-1001",
      "amount": "25.00",
      "confirmations": 20,
      "confirmations_required": 20,
      "status": "confirmed"
    }
  ]
}

➡️ confirmed = credit · pending = wait · ignored = below minimum

Example 4

Withdraw coins

Situation: Withdraw USDT to your own wallet

Request
POST /v1/crypto/withdrawals
{
  "asset": "USDT-TRC20",
  "to_address": "T…your address…",
  "amount": "100"
}

➡️ 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).

🚦 System status (GET /status)

Check any time whether the API is healthy — no key needed

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

  • 🟢 ok = normal
  • 🟠 busy = high traffic
  • 🔴 slow = minor delays
  • Measured from real requests over the last 5 minutes, per service (services[]). Slip verification and slip deposits are measured across every backup provider, with each route's state in routes[]
  • No API key; callable from browsers (CORS open); cached 15 s — poll at most once a minute
  • On busy/slow, raise your timeout to 15–20 s and retry with the same Idempotency-Key — you are never charged twice
  • paused[] lists service codes TUNGKAO has switched off for now (e.g. line_login) — grey that button out and show “System temporarily unavailable” (API calls return 503 SERVICE_PAUSED, nothing charged)
  • Also shown at the top right of tungkao.com
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"
  }
}

🛡️ Stability promise: integrate once, keep working

  • API /v1 is frozen: nothing is removed, renamed or retyped — only new fields or endpoints are added. Automated contract tests block any deploy that would break existing code.
  • When providers (banks, LINE, Google, Facebook, TikTok, Discord, Telegram, blockchains) change, we adapt on our servers — your code stays the same. Slip checks fail over across 3 providers automatically.
  • Write future-proof code: ignore unknown fields, branch on error.code (not message text), and treat an unknown new status as “not passed / pending”.
  • If something ever must be retired, we announce it at least 12 months ahead via Deprecation / Sunset headers on every response, email and webhook — the old behaviour keeps working until then.
  • Every response carries an X-Tungkao-Api-Version header with the version and latest revision date. Full history: /changelog.json

🏷️ TUNGKAO attribution requirement

  • Every page or screen that uses a TUNGKAO service (slip check, deposits, crypto, login, notifications) must show visible “Powered by TUNGKAO” or “Secured by TUNGKAO” text linking to https://tungkao.com
  • Place it near the feature — under the sign-in button, under the slip upload, or on the payment page. Do not hide it, blend it into the background or make it unreadably small
  • Buttons from the “Login buttons” page include the credit automatically, and the hosted TUNGKAO sign-in page shows it itself
  • Example: <a href="https://tungkao.com" target="_blank" rel="noopener">Powered by TUNGKAO</a>
  • To remove the credit, buy the White-label add-on for that key on the API keys page in the portal (30 days at a time)

Powered by TUNGKAO