Developer API — TikTok Shop Affiliate

Tạo & quản lý API key, gọi API tạo link affiliate và lấy đơn hàng từ hệ thống của bạn.

Tài liệu cập nhật: 11/06/2026

API Keys của bạn

Key dùng ở header X-Riohub-Api-Key. Mỗi key chỉ thao tác được trên creator TikTok mà chính tài khoản này đã kết nối.

Lưu lại ngay! Key chỉ hiển thị một lần. Sau khi đóng bạn sẽ không xem lại được.
TênPrefixTrạng tháiDùng lần cuốiTạo lúc
Đang tải...
Hướng dẫn sử dụng

Base URL:

1. Xác thực

Mọi request gửi kèm header API key:

X-Riohub-Api-Key: rhk_xxxxxxxxxxxxxxxxxxxxxxxx

Lỗi xác thực trả về 401. Gọi creator không thuộc tài khoản của bạn trả về 403.

Giới hạn tần suất: mỗi key tối đa 300 request/phút100.000 request/ngày. Vượt giới hạn trả về 429 kèm header Retry-After.

POST

Tạo link affiliate

Tạo link tiếp thị cho một sản phẩm, gắn nhãn theo dõi (sub_id).

Body (JSON):

FieldBắt buộcMô tả
creator_usernameUsername TikTok creator (đã kết nối ở tài khoản của bạn).
product_urlCó*URL sản phẩm (link rút gọn vt.tiktok.com, link trực tiếp, hoặc product_id). *hoặc product_id.
sub_idNhãn theo dõi, 1–128 ký tự [A-Za-z0-9_-].
typeKhôngMặc định PRODUCT.

Ví dụ (cURL):

Phản hồi 200:

{ "affiliate_link": "https://vt.tiktok.com/XXXXXX/", "sub_id": "fb-ads-01", "product_id": "1729...", "creator_username": "your_creator" }

Sản phẩm không có hoa hồng / chưa được duyệt → 422 code product_not_promotable.

GET

Lấy thông tin sản phẩm affiliate

API tạo link không kèm thông tin sản phẩm — endpoint này trả tên/ảnh/giá/hoa hồng theo product_id (trong phạm vi quyền của creator). RioHub cache 24h: id đã có trả ngay, id mới/quá hạn mới gọi TikTok.

Query params:

ParamBắt buộcMô tả
creator_usernameUsername TikTok creator (đã kết nối).
product_id1 id hoặc danh sách phân tách dấu phẩy (tối đa 100).

Phản hồi 200:

{ "creator_username": "your_creator", "requested": 1, "found": 1, "products": [ { "id": "1732152247872817576", "title": "Bộ Cạo Râu 72 Lưỡi + 2 cán Dao Làm và Hộp Nhựa", "main_image_url": "https://p16-oec-sg.ibyteimg.com/.../image", "detail_link": "https://shop.tiktok.com/view/product/1732152247872817576?region=VN", "sale_region": "VN", "has_inventory": true, "units_sold": 62030, "commission": { "rate": 600, "amount": "3299.94 - 5099.94", "currency": "VND" }, "shop_ads_commission": { "rate": 200 }, "sales_price": { "minimum_amount": "", "maximum_amount": "", "currency": "" }, "original_price": { "minimum_amount": "89000", "maximum_amount": "139000", "currency": "VND" }, "shop": { "name": "Nấmm Decor" }, "category_chains": [ { "id": "601450", "is_leaf": false, "local_name": "Chăm sóc sắc đẹp & cá nhân", "parent_id": "0" }, { "id": "700791", "is_leaf": true, "local_name": "Dao cạo", "parent_id": "849288" } ] } ], "not_found": [] }

Giải thích field trong products[] (passthrough TikTok V202509):

FieldTypeMô tả
idstringMã sản phẩm (int64 dạng chuỗi).
titlestringTên sản phẩm.
main_image_urlstringẢnh chính.
detail_linkstringLink trang sản phẩm trên TikTok Shop.
sale_regionstringKhu vực bán (vd VN).
has_inventorybooltrue = còn hàng.
units_soldnumberTổng số đã bán (lũy kế).
commission.ratenumberTỷ lệ hoa hồng raw, ÷100 = % (vd 600 = 6%).
commission.amountstringHoa hồng ước tính — có thể là 1 khoảng (vd "3299.94 - 5099.94") khi nhiều SKU giá khác nhau.
shop_ads_commission.ratenumberTỷ lệ HH cho đơn Shop Ads (raw, ÷100 = %).
sales_price.{min,max}_amountstringGiá bán hiện tại (khoảng). Có thể rỗng "" nếu TikTok không trả → dùng original_price.
original_price.{min,max}_amountstringGiá gốc (khoảng).
shop.namestringTên shop.
category_chains[]arrayCây ngành hàng (gốc → lá); phần tử is_leaf:true là ngành lá.

products[] giữ nguyên object từ TikTok. Id không lấy được (không đủ điều kiện / không tồn tại) nằm trong not_found. Dữ liệu cache 24h.

GET

Lấy đơn hàng

Truy vấn đơn affiliate đã đồng bộ theo creator và khoảng thời gian.

Query params:

ParamBắt buộcMô tả
creator_usernameCreator thuộc tài khoản của bạn.
time_startKhôngUnix giây hoặc Y-m-d H:i:s — lọc theo ngày tạo (từ).
time_endKhôngUnix giây hoặc Y-m-d H:i:s — lọc theo ngày tạo (đến, không bao gồm).
update_time_startKhôngUnix giây — lọc theo thời điểm đơn được cập nhật (từ). Dùng kéo đơn vừa đổi settlement/refund (sync tăng dần).
update_time_endKhôngUnix giây — lọc theo ngày cập nhật (đến, không bao gồm).
order_idKhông1 mã đơn hoặc danh sách ngăn cách dấu phẩy (tối đa 200) — verify postback / gom 1 đợt. Nên đặt page_size đủ lớn.
product_idKhông1 hoặc list (tối đa 100) — lọc đơn theo sản phẩm.
statusKhông1 hoặc list: 1=pending · 2=settled · 3=cancelled/refunded.
settlement_statusKhông1 hoặc list (passthrough TikTok, vd SETTLED,AWAITING PAYMENT).
content_typeKhông1 hoặc list: VIDEO / LIVE / SHOWCASE / LINKSHARE (passthrough).
fully_refundedKhông0 | 1 — lọc đơn hoàn toàn bộ.
sub_idKhôngKhớp chuỗi con trên tag (vd abc khớp abc-def--).
sub1sub4KhôngKhớp chính xác từng vị trí của tag (tag tách bằng -); kết hợp nhiều sub = AND.
page / page_sizeKhôngPhân trang (mặc định 1 / 50, tối đa 200).

Ví dụ (cURL):

Phản hồi 200:

{ "creator_username": "your_creator", "page": 1, "page_size": 50, "total": 12, "orders": [ { "order_id": "579012345678901234", "sku_id": "173098765432109876", "product_id": "172900112233445566", "product_name": "Áo thun cotton unisex", "price": "199000.00", "quantity": 1, "refunded_quantity": 0, "returned_quantity": 0, "fully_refunded": 0, "creator_username": "your_creator", "shop_name": "Rio Official Store", "currency": "VND", "settlement_status": "AWAITING PAYMENT", "status": 1, "tt_order_status": 100, "content_type": "LINKSHARE", "content_id": "744011223344556677", "sub_id": "u27765-m1780903356", "sub1": "u27765", "sub2": "m1780903356", "sub3": "", "sub4": "", "commission_model": "Fixed commission", "standard_commission_rate": "800", "commission_gmv": "199000.00", "est_standard_commission": "19900.00", "est_commission": "19900.00", "actual_commission": null, "create_time": 1749513600, "update_time": 1749520800, "time_created": "2026-06-10 08:00:00", "time_delivered": null, "payment_status": "AWAITING PAYMENT" } ] }

Chi tiết field trong orders[]:

Kiểu JSON: cột số nguyên trả về number; cột tiền/decimal & ID lớn trả về string (giữ nguyên độ chính xác).

FieldTypeGiá trị / EnumMô tả
order_idstringMã đơn TikTok (int64 dạng chuỗi).
sku_idstringMã SKU. Một đơn nhiều SKU = nhiều dòng (mỗi dòng 1 SKU).
product_idstringMã sản phẩm.
product_namestringTên sản phẩm.
pricestringĐơn giá GMV (decimal dạng chuỗi).
quantitynumberSố lượng đặt.
refunded_quantitynumberSL đã hoàn tiền.
returned_quantitynumberSL đã trả hàng.
fully_refundednumber0 · 11 = đơn đã hoàn toàn bộ số lượng.
currencystringVND, USD, …Mã tiền tệ ISO-4217.
settlement_statusstringAWAITING PAYMENT · To-SETTLE · SETTLED · REFUNDEDTrạng thái gốc từ TikTok (passthrough). TikTok có thể bổ sung trạng thái khác.
statusnumber1 · 2 · 3Trạng thái chuẩn hoá: 1=chờ/pending · 2=đã đối soát/settled · 3=huỷ/hoàn.
tt_order_statusnumber100 · 103 · 104Tương ứng status: 100=pending · 103=settled · 104=cancelled/refunded.
content_typestringVIDEO · LIVE · SHOWCASE · LINKSHARE · …Nguồn nội dung phát sinh đơn (passthrough). LINKSHARE = từ link chia sẻ.
content_idstringID video / live / showcase nguồn (rỗng nếu không có).
sub_idstringNhãn theo dõi bạn gắn lúc tạo link (= tag đầy đủ).
sub1sub4string · nullTag tách theo - thành 4 vị trí (vd u27765-m178... → sub1=u27765, sub2=m178...). Vị trí trống = ""; đơn không có tag = null. Dùng lọc qua param sub1sub4.
commission_modelstringpassthrough TikTokMô hình hoa hồng, vd Fixed commission. Giá trị do TikTok định nghĩa.
standard_commission_ratenumberraw, ÷100 = %Tỷ lệ HH chuẩn dạng raw int, vd 1000 = 10%.
commission_gmvstringGMV dùng để tính hoa hồng (decimal chuỗi).
est_standard_commissionstringHoa hồng chuẩn ước tính.
est_commissionstringHoa hồng ròng ước tính của creator (gồm cả đơn pending).
actual_commissionstring · nullnull khi chưa đối soátHoa hồng thực nhận sau đối soát.
create_timenumberunix giâyThời điểm tạo đơn.
update_timenumberunix giâyLần cập nhật cuối.
time_createdstringY-m-d H:i:screate_time dạng ngày giờ.
time_deliveredstring · nullY-m-d H:i:sThời điểm giao hàng (null nếu chưa giao).
payment_statusstringnhư settlement_statusTrạng thái thanh toán gốc từ TikTok.

GET

Lấy danh sách link đã tạo

Liệt kê các link affiliate bạn đã tạo qua API (nguồn api) cho creator, kèm số đơn & hoa hồng tổng hợp theo sub_id.

Query params:

ParamBắt buộcMô tả
creator_usernameCreator thuộc tài khoản của bạn.
sub_idKhôngLọc theo nhãn theo dõi.
channelKhôngLọc theo nhãn nguồn traffic.
time_startKhôngUnix giây hoặc Y-m-d H:i:s (lọc từ ngày tạo).
time_endKhôngUnix giây hoặc Y-m-d H:i:s (lọc đến, không bao gồm).
page / page_sizeKhôngPhân trang (mặc định 1 / 50, tối đa 200).

Ví dụ (cURL):

Phản hồi 200:

{ "creator_username": "your_creator", "page": 1, "page_size": 50, "total": 8, "links": [ { "id": 42, "material_type": "PRODUCT", "material_id": "1729...", "affiliate_link": "https://vt.tiktok.com/XXXXXX/", "channel": "riokupon", "sub_id": "fb-ads-01", "order_count": 3, "est_commission": "37.50", "settled_commission": "12.50", "currency": "VND", "created_at": "..." } ] }

Chi tiết field trong links[]:

FieldTypeGiá trị / EnumMô tả
idnumberID nội bộ của link trên RioHub.
material_typestringPRODUCT · CAMPAIGN · SHOWCASELoại đối tượng được gắn link.
material_idstringID sản phẩm/chiến dịch/showcase.
affiliate_linkstringLink affiliate đã tạo.
channelstringmặc định riokuponNhãn nguồn traffic bạn gắn lúc tạo link.
sub_idstringNhãn theo dõi (= tag).
order_countnumberSố đơn tổng hợp theo sub_id.
est_commissionstringHoa hồng ước tính (gồm pending).
settled_commissionstringHoa hồng đã đối soát.
currencystringVND, …Mã tiền tệ ISO-4217.
created_atstringY-m-d H:i:sThời điểm tạo link.
Code mẫu

Sao chép & thay YOUR_API_KEY bằng key của bạn. creator_username tự điền creator đã kết nối của bạn (nếu có).

# 1) Tạo link affiliate curl -X POST '__BASE__/partner/tiktok/affiliate/links' \ -H 'X-Riohub-Api-Key: YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"creator_username":"__CREATOR__","product_url":"https://vt.tiktok.com/XXXXXX/","sub_id":"fb-ads-01"}' # 2) Lấy danh sách link đã tạo curl '__BASE__/partner/tiktok/affiliate/links?creator_username=__CREATOR__&page=1&page_size=50' \ -H 'X-Riohub-Api-Key: YOUR_API_KEY' # 3) Lấy đơn hàng (lọc theo order_id / settlement_status — đều tuỳ chọn) curl '__BASE__/partner/tiktok/affiliate/orders?creator_username=__CREATOR__&order_id=579,580&settlement_status=SETTLED&page=1&page_size=50' \ -H 'X-Riohub-Api-Key: YOUR_API_KEY' # 4) Lấy thông tin sản phẩm affiliate curl '__BASE__/partner/tiktok/affiliate/products?creator_username=__CREATOR__&product_id=1729...,1730...' \ -H 'X-Riohub-Api-Key: YOUR_API_KEY'
<?php $base = '__BASE__'; $key = 'YOUR_API_KEY'; // 1) Tạo link affiliate $ch = curl_init("$base/partner/tiktok/affiliate/links"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => ["X-Riohub-Api-Key: $key", "Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode([ "creator_username" => "__CREATOR__", "product_url" => "https://vt.tiktok.com/XXXXXX/", "sub_id" => "fb-ads-01", ]), ]); $link = json_decode(curl_exec($ch), true); curl_close($ch); echo $link["affiliate_link"] ?? "error"; // 2) Lấy danh sách link đã tạo $q = http_build_query(["creator_username" => "__CREATOR__", "page" => 1, "page_size" => 50]); $ch = curl_init("$base/partner/tiktok/affiliate/links?$q"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["X-Riohub-Api-Key: $key"], ]); $links = json_decode(curl_exec($ch), true); curl_close($ch); print_r($links["links"] ?? []); // 3) Lấy đơn hàng (tất cả filter đều tuỳ chọn) $q = http_build_query([ "creator_username" => "__CREATOR__", "order_id" => "584428814795835227,583754926547633737", // 1 hoặc list (verify postback) "status" => "1,2", // 1=pending 2=settled 3=cancelled "settlement_status" => "SETTLED", "update_time_start" => 1778000000, // chỉ đơn cập nhật sau mốc này (sync tăng dần) "sub1" => "u27765", // khớp vị trí 1 của tag "page" => 1, "page_size" => 200, ]); $ch = curl_init("$base/partner/tiktok/affiliate/orders?$q"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["X-Riohub-Api-Key: $key"], ]); $orders = json_decode(curl_exec($ch), true); curl_close($ch); print_r($orders["orders"] ?? []); // 4) Lấy thông tin sản phẩm affiliate (1 hoặc nhiều product_id) $q = http_build_query(["creator_username" => "__CREATOR__", "product_id" => "1732152247872817576"]); $ch = curl_init("$base/partner/tiktok/affiliate/products?$q"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["X-Riohub-Api-Key: $key"], ]); $products = json_decode(curl_exec($ch), true); curl_close($ch); print_r($products["products"] ?? []);
const BASE = '__BASE__'; const KEY = 'YOUR_API_KEY'; // 1) Tạo link affiliate const link = await fetch(`${BASE}/partner/tiktok/affiliate/links`, { method: 'POST', headers: { 'X-Riohub-Api-Key': KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ creator_username: '__CREATOR__', product_url: 'https://vt.tiktok.com/XXXXXX/', sub_id: 'fb-ads-01', }), }).then(r => r.json()); console.log(link.affiliate_link); // 2) Lấy danh sách link đã tạo const lq = new URLSearchParams({ creator_username: '__CREATOR__', page: '1', page_size: '50' }); const links = await fetch(`${BASE}/partner/tiktok/affiliate/links?${lq}`, { headers: { 'X-Riohub-Api-Key': KEY }, }).then(r => r.json()); console.log(links.total, links.links); // 3) Lấy đơn hàng (tất cả filter đều tuỳ chọn) const q = new URLSearchParams({ creator_username: '__CREATOR__', order_id: '584428814795835227,583754926547633737', // 1 hoặc list (verify postback) status: '1,2', // 1=pending 2=settled 3=cancelled settlement_status: 'SETTLED', update_time_start: '1778000000', // chỉ đơn cập nhật sau mốc này (sync tăng dần) sub1: 'u27765', // khớp vị trí 1 của tag page: '1', page_size: '200', }); const orders = await fetch(`${BASE}/partner/tiktok/affiliate/orders?${q}`, { headers: { 'X-Riohub-Api-Key': KEY }, }).then(r => r.json()); console.log(orders.total, orders.orders); // 4) Lấy thông tin sản phẩm affiliate (1 hoặc nhiều product_id) const pq = new URLSearchParams({ creator_username: '__CREATOR__', product_id: '1732152247872817576' }); const products = await fetch(`${BASE}/partner/tiktok/affiliate/products?${pq}`, { headers: { 'X-Riohub-Api-Key': KEY }, }).then(r => r.json()); console.log(products.found, products.products);
import requests BASE = "__BASE__" KEY = "YOUR_API_KEY" H = {"X-Riohub-Api-Key": KEY} # 1) Tạo link affiliate link = requests.post(f"{BASE}/partner/tiktok/affiliate/links", headers=H, json={ "creator_username": "__CREATOR__", "product_url": "https://vt.tiktok.com/XXXXXX/", "sub_id": "fb-ads-01", }).json() print(link.get("affiliate_link")) # 2) Lấy danh sách link đã tạo links = requests.get(f"{BASE}/partner/tiktok/affiliate/links", headers=H, params={ "creator_username": "__CREATOR__", "page": 1, "page_size": 50, }).json() print(links.get("total"), links.get("links")) # 3) Lấy đơn hàng (tất cả filter đều tuỳ chọn) orders = requests.get(f"{BASE}/partner/tiktok/affiliate/orders", headers=H, params={ "creator_username": "__CREATOR__", "order_id": "584428814795835227,583754926547633737", # 1 hoặc list (verify postback) "status": "1,2", # 1=pending 2=settled 3=cancelled "settlement_status": "SETTLED", "update_time_start": 1778000000, # chỉ đơn cập nhật sau mốc này (sync tăng dần) "sub1": "u27765", # khớp vị trí 1 của tag "page": 1, "page_size": 200, }).json() print(orders.get("total"), orders.get("orders")) # 4) Lấy thông tin sản phẩm affiliate (1 hoặc nhiều product_id) products = requests.get(f"{BASE}/partner/tiktok/affiliate/products", headers=H, params={ "creator_username": "__CREATOR__", "product_id": "1732152247872817576", }).json() print(products.get("found"), products.get("products"))
Tích hợp bằng AI

Sao chép cả khối Markdown dưới đây, dán cho AI (ChatGPT/Claude/Copilot…) kèm yêu cầu của bạn — AI sẽ tự viết code tích hợp. Không chứa key thật: giữ YOUR_API_KEY và thay bằng key của bạn lúc chạy.

# RioHub × TikTok Shop Affiliate API — Spec tích hợp > Tài liệu cập nhật: 11/06/2026 Bạn là kỹ sư tích hợp. Hãy viết code gọi các API dưới đây theo ngôn ngữ tôi chỉ định. Đọc API key từ biến môi trường (KHÔNG hardcode, KHÔNG để lộ key); thay `YOUR_API_KEY` bằng key thật khi chạy. ## Base URL `__BASE__` ## Xác thực Mọi request kèm header: `X-Riohub-Api-Key: YOUR_API_KEY` - `401` key sai/thiếu · `403` creator không thuộc tài khoản của key · `404` creator chưa kết nối - `429` vượt giới hạn (300 req/phút, 100.000 req/ngày) — đọc header `Retry-After` rồi thử lại. ## 1) POST `/partner/tiktok/affiliate/links` — Tạo link affiliate Body JSON: - `creator_username` (bắt buộc): username creator đã kết nối, vd `__CREATOR__` - `product_url` (bắt buộc*): URL sản phẩm (link rút gọn vt.tiktok.com / link trực tiếp) hoặc `product_id`. (*hoặc gửi `product_id`) - `sub_id` (bắt buộc): nhãn theo dõi, 1–128 ký tự `[A-Za-z0-9_-]`. Có thể gói tối đa 4 sub theo vị trí, phân tách bằng `-` (vd `abc-def--` → sub1=abc, sub2=def, sub3/4=rỗng); RioHub tự tách thành `sub1..sub4` để lọc đơn theo từng vị trí. Lưu ý: giá trị mỗi sub KHÔNG được chứa `-` (đó là dấu phân tách). - `type` (tuỳ chọn): mặc định `PRODUCT` - `channel` (tuỳ chọn): nhãn nguồn traffic, mặc định `riokupon`. 1–64 ký tự `[A-Za-z0-9_-]` Request: { "creator_username": "__CREATOR__", "product_url": "https://vt.tiktok.com/XXXXXX/", "sub_id": "fb-ads-01" } Response 200: { "affiliate_link": "https://vt.tiktok.com/XXXXXX/", "sub_id": "fb-ads-01", "product_id": "1729...", "creator_username": "__CREATOR__" } Lỗi 422 `product_not_promotable`: sản phẩm không có hoa hồng hoặc chưa được shop duyệt. ## 2) GET `/partner/tiktok/affiliate/links` — Lấy danh sách link đã tạo Liệt kê link đã tạo qua API (source=`api`) cho creator, kèm số đơn & hoa hồng theo `sub_id`. Query params: - `creator_username` (bắt buộc) - `sub_id` (tuỳ chọn): khớp **chuỗi con** trên tag; `channel` (tuỳ chọn): lọc nguồn traffic - `sub1`, `sub2`, `sub3`, `sub4` (tuỳ chọn): lọc khớp chính xác theo từng vị trí của tag - `time_start`, `time_end` (tuỳ chọn): unix giây hoặc `Y-m-d H:i:s` (lọc theo ngày tạo, end không bao gồm) - `page` (mặc định 1), `page_size` (mặc định 50, tối đa 200) Response 200: { "creator_username": "__CREATOR__", "page": 1, "page_size": 50, "total": 8, "links": [ { "id": 42, "material_id": "1729...", "affiliate_link": "https://vt.tiktok.com/XXXXXX/", "channel": "riokupon", "sub_id": "fb-ads-01", "order_count": 3, "est_commission": "37.50", "settled_commission": "12.50", "currency": "VND", "created_at": "..." } ] } ## 3) GET `/partner/tiktok/affiliate/orders` — Lấy đơn hàng Query params: - `creator_username` (bắt buộc) - `time_start`, `time_end` (tuỳ chọn): unix giây hoặc `Y-m-d H:i:s` (lọc từ / đến, end không bao gồm) - `sub_id` (tuỳ chọn): khớp **chuỗi con** trên tag đầy đủ (vd `abc` khớp `abc-def---`) - `sub1`, `sub2`, `sub3`, `sub4` (tuỳ chọn): lọc **khớp chính xác** theo từng vị trí của tag (tag tách bằng `-`); kết hợp nhiều sub = AND - `order_id` (tuỳ chọn): 1 mã đơn hoặc danh sách phân tách bằng dấu phẩy (tối đa 200) — dùng để verify postback hoặc gom 1 đợt (vd hold postback ~5p rồi lấy 1 loạt). Nên đặt `page_size` đủ lớn. - `settlement_status` (tuỳ chọn): 1 giá trị hoặc danh sách phân tách bằng dấu phẩy (vd `SETTLED,AWAITING PAYMENT`) - `status` (tuỳ chọn): trạng thái chuẩn hoá, 1 giá trị hoặc list (`1`=pending · `2`=settled · `3`=cancelled/refunded) - `update_time_start`, `update_time_end` (tuỳ chọn): unix giây, lọc theo thời điểm đơn **được cập nhật** (end không bao gồm) — dùng để kéo đơn vừa đổi settlement/refund (sync tăng dần) - `product_id` (tuỳ chọn): 1 hoặc list (tối đa 100) — lọc đơn theo sản phẩm - `content_type` (tuỳ chọn): 1 hoặc list, theo nguồn nội dung (VIDEO/LIVE/SHOWCASE/LINKSHARE — passthrough) - `fully_refunded` (tuỳ chọn): `0` | `1` - `page` (mặc định 1), `page_size` (mặc định 50, tối đa 200) Response 200: { "creator_username": "__CREATOR__", "page": 1, "page_size": 50, "total": 12, "orders": [ { "order_id": "...", "sku_id": "...", "product_id": "...", "product_name": "...", "sub_id": "abc-def--", "sub1": "abc", "sub2": "def", "sub3": "", "sub4": "", "quantity": 1, "refunded_quantity": 0, "fully_refunded": 0, "est_commission": "12.50", "actual_commission": null, "currency": "VND", "settlement_status": "AWAITING PAYMENT", "status": 1, "tt_order_status": 100, "content_type": "VIDEO", "create_time": 1749513600 } ] } Kiểu JSON: cột số nguyên = number, cột tiền/decimal & ID lớn = string. Enum các field trạng thái trong orders[]: - `status` (number): 1=pending · 2=settled · 3=cancelled/refunded - `tt_order_status` (number): 100=pending · 103=settled · 104=cancelled/refunded - `settlement_status` / `payment_status` (string, passthrough TikTok): AWAITING PAYMENT · To-SETTLE · SETTLED · REFUNDED - `fully_refunded` (number): 0 | 1 - `content_type` (string, passthrough): VIDEO · LIVE · SHOWCASE · LINKSHARE · … - `actual_commission` (string|null): null khi chưa đối soát - `sub1`..`sub4` (string): tag tách theo `-` (vị trí trống = `""`) ## 4) GET `/partner/tiktok/affiliate/products` — Lấy thông tin sản phẩm affiliate API tạo link không kèm thông tin sản phẩm — dùng endpoint này lấy tên/ảnh/giá/hoa hồng theo `product_id` (trong phạm vi quyền của creator). RioHub cache thông tin sản phẩm 24h: id đã có trong cache trả về ngay, id mới/quá 24h mới gọi TikTok → giảm tải, nhanh hơn. Query params: - `creator_username` (bắt buộc) - `product_id` (bắt buộc): 1 id hoặc danh sách phân tách bằng dấu phẩy (tối đa 100) Response 200 (`products[]` = object passthrough TikTok V202509, snake_case): { "creator_username": "__CREATOR__", "requested": 1, "found": 1, "products": [ { "id": "1732...", "title": "...", "main_image_url": "https://...", "detail_link": "https://shop.tiktok.com/view/product/1732...", "sale_region": "VN", "has_inventory": true, "units_sold": 62030, "commission": { "rate": 600, "amount": "3299.94 - 5099.94", "currency": "VND" }, "shop_ads_commission": { "rate": 200 }, "sales_price": { "minimum_amount": "", "maximum_amount": "", "currency": "" }, "original_price": { "minimum_amount": "89000", "maximum_amount": "139000", "currency": "VND" }, "shop": { "name": "..." }, "category_chains": [ { "id": "700791", "is_leaf": true, "local_name": "Dao cạo", "parent_id": "849288" } ] } ], "not_found": [] } Ghi chú field: `commission.rate` raw ÷100 = % (600 = 6%); `commission.amount` có thể là khoảng "min - max"; `sales_price` có thể rỗng → dùng `original_price`; `units_sold` lũy kế; `has_inventory` còn hàng; ngành lá = phần tử `is_leaf:true`. Id không lấy được (không đủ điều kiện / không tồn tại) nằm trong `not_found`. Dữ liệu cache 24h. ## 5) Postback (webhook) — RioHub POST về URL của bạn Event JSON: `event` ∈ { order.created, order.updated, order.refunded }; `event_id` (UUID) idempotency; `occurred_at` ISO-8601. `data` chứa các field như orders[] (status 1/2/3, order_status_raw = settlement_status gốc). Xác minh chữ ký header `X-Riohub-Signature: t=,v1=`. ## Yêu cầu code - Đọc key từ env; có cơ chế retry khi gặp 429 (tôn trọng `Retry-After`). - Bắt và log rõ các lỗi 401/403/404/422. - Hàm tạo link nhận (product_url, sub_id) và trả về `affiliate_link`.
Thử nghiệm trực tiếp

Nhập dữ liệu và gọi API thật bằng key của bạn — phản hồi hiển thị bên dưới.

Tự dùng key của tài khoản này (tạo sẵn 1 key "Playground" khi bạn bấm Gửi). Hoặc dán key khác để thử.
Phản hồi
Postback qua Callback URL

RioHub POST JSON có chữ ký HMAC về URL của bạn mỗi khi đơn affiliate phát sinh / cập nhật / hoàn. Theo tài khoản (1 endpoint), áp dụng mọi creator đã kết nối. Bỏ trống URL nếu chỉ dùng Telegram bên dưới.

Nếu dùng: phải HTTPS, trả về HTTP 2xx trong vòng 5s để xác nhận đã nhận. Để trống nếu chỉ dùng Telegram.
Giữ bí mật. Mỗi request kèm header X-Riohub-Signature: t=<ts>,v1=<hmac>.
Mẫu payload (body POST)
{ "event_id": "f1e2...-uuid", "event": "order.created", "occurred_at": "2026-06-10T04:18:00+00:00", "data": { "order_id": "5790...", "sku_id": "1730...", "product_id": "1729...", "product_name": "...", "creator_username": "your_creator", "currency": "VND", "quantity": 1, "refunded_quantity": 0, "fully_refunded": 0, "status": 1, "order_status_raw": "AWAITING PAYMENT", "actual_commission": null, "subid": "abc-def-ghi-jkl", "sub1": "abc", "sub2": "def", "sub3": "ghi", "sub4": "jkl" } }

Chi tiết field:

FieldTypeGiá trị / EnumMô tả
event_idstringUUIDID sự kiện, ổn định để chống xử lý trùng (idempotency).
eventstringorder.created · order.updated · order.refundedLoại sự kiện (trùng danh sách "Sự kiện đăng ký" ở trên).
occurred_atstringISO-8601Thời điểm phát sinh sự kiện.
data.order_idstringMã đơn TikTok.
data.sku_idstringMã SKU.
data.quantitynumberSố lượng đặt.
data.refunded_quantitynumberSL đã hoàn.
data.fully_refundednumber0 · 11 = đã hoàn toàn bộ.
data.statusnumber1 · 2 · 31=pending · 2=settled · 3=refunded/cancelled.
data.order_status_rawstringAWAITING PAYMENT · To-SETTLE · SETTLED · REFUNDEDTrạng thái gốc TikTok (passthrough).
data.actual_commissionstring · nullnull khi chưa đối soátHoa hồng thực nhận.
data.subidstringvd abc-def-ghi-jklSub_id đầy đủ (tag gốc) gắn vào link affiliate.
data.sub1data.sub4stringsubid tách theo dấu - (vị trí 1–4); rỗng nếu không có.

Các field còn lại trong data (product_id, product_name, creator_username, currency, returned_quantity) cùng kiểu & ý nghĩa như ở API Lấy đơn hàng.

Xác minh chữ ký (PHP)
<?php $secret = 'YOUR_SIGNING_SECRET'; $raw = file_get_contents('php://input'); // body thô, KHÔNG decode $sig = $_SERVER['HTTP_X_RIOHUB_SIGNATURE'] ?? ''; // "t=...,v1=..." parse_str(str_replace(',', '&', $sig), $p); $expected = hash_hmac('sha256', ($p['t'] ?? '') . '.' . $raw, $secret); if (!hash_equals($expected, $p['v1'] ?? '')) { http_response_code(403); exit('bad signature'); } // (tuỳ chọn) chống replay: từ chối nếu abs(time() - $p['t']) > 300 $event = json_decode($raw, true); // ... xử lý $event['event'] / $event['data'] ... http_response_code(200); echo 'ok';

Retry: nếu không nhận 2xx, RioHub thử lại theo backoff 1m → 5m → 30m → 2h → 6h (tối đa 6 lần) rồi đánh dấu dead.

Lịch sử gửi gần đây
Thời điểmSự kiệnOrderPostback (HTTP)TelegramLần thửLỗi
Thông báo qua Telegram

Gửi 1 tin nhắn tóm tắt mỗi đơn về Telegram của bạn — kênh độc lập, dùng bot riêng. Lưu riêng, không ảnh hưởng cấu hình URL ở trên. Cách lấy token & chat ID ▾

Chưa bật
  1. Mở @BotFather trên Telegram → gửi /newbot → nhận bot token dạng 123456789:ABC-def....
  2. Nhắn cho bot (chat riêng), hoặc thêm bot vào group/channel.
  3. Lấy chat ID: mở https://api.telegram.org/bot<token>/getUpdates sau khi nhắn bot → copy chat.id. Channel công khai dùng @tenkenh.
Token được lưu phía máy chủ, không hiển thị lại.
Để trống & lưu = tắt Telegram.

Nút Gửi test bắn 1 tin ping tới mọi kênh đang bật (URL & Telegram).

Về TikTok Shop