VI | EN
Message us on Messenger
Developer resources

Send IM Message — TikTok Shop API

tiktok.affiliate_seller.202412.conversations.conversation_id.messages · call it through Quantri360 with one API key for your own accounts / assets that you connected and authorized — 360 handles request signing and refreshing the authorization you granted.

tiktok.affiliate_seller.202412.conversations.conversation_id.messages

POST/affiliate_seller/202412/conversations/{conversation_id}/messagesVia 360: POST https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/{conversation_id}/messages
Write endpoint — changes data on TikTok Shop. The key must be created with "Allow write API calls" ticked, otherwise you get 403 write_not_allowed. Every call is logged.
Description

Gửi tin nhắn thuộc loại đã chọn trong cuộc hội thoại với creator.

  • Gọi qua /v1/tiktok/affiliate_seller/202412/conversations/{conversation_id}/messages với Authorization: Bearer <key>; dùng platform_shop_id khi có nhiều shop. 360 tự gắn app_key, shop_cipher, sign và access_token.
  • API GHI: thay đổi dữ liệu thật trên TikTok Shop; cần key có quyền ghi (can_write) và gói mở module affiliate. Gửi tin nhắn thuộc loại đã chọn trong cuộc hội thoại với creator.
  • HTTP 200 vẫn có thể có lỗi nghiệp vụ; kiểm code trước khi dùng kết quả.

Request

Endpoint

POST https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/{conversation_id}/messages

Authentication & shop

NameInTypeSampleDescription
AuthorizationheaderheaderBearer q360_live_ab12cd34_…Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand.
platform_shop_idquerystring100001Gian hàng (lấy ở GET /v1/platforms → shops[].platform_shop_id). BẮT BUỘC khi brand có > 1 gian hàng trên nền tảng; 360 bỏ tham số này trước khi chuyển tiếp.

Request parameters

NameInTypeRequiredSampleDescription
conversation_idpathstringYes100000000000000101Mã cuộc hội thoại.
msg_typebodystringYesTEXTLoại tin nhắn: TEXT, PRODUCT_CARD, TARGET_COLLABORATION_CARD, FREE_SAMPLE_CARD, IMAGE, CRM_TEXT_WITH_IMAGE_CARD hoặc CRM_TEXT_WITH_PRODUCTS_CARD; quyết định cấu trúc JSON bên trong content.
contentbodystringYes{"content":"Xin chào, mời hợp tác"}Chuỗi JSON theo msg_type. TEXT: content bắt buộc, không rỗng, tối đa 2000 ký tự Unicode. PRODUCT_CARD: product_id. TARGET_COLLABORATION_CARD: target_collaboration_id (mã nhóm lời mời). FREE_SAMPLE_CARD: apply_id. IMAGE: url, width và height (số nguyên). CRM_TEXT_WITH_PRODUCTS_CARD: product_ids là 1–5 mã dương cách nhau dấu phẩy, content không rỗng tối đa 500 ký tự, title tối đa 50. CRM_TEXT_WITH_IMAGE_CARD: image_url và content không rỗng tối đa 500 ký tự, title tối đa 50.

Request examples

curl -s -X POST "https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/100000000000000101/messages" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"msg_type":"TEXT","content":"{\"content\":\"Xin chào, mời hợp tác\"}"}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/100000000000000101/messages",
    params={},
    json={
        "msg_type": "TEXT",
        "content": "{\"content\":\"Xin chào, mời hợp tác\"}"
    },
    headers={"Authorization": f"Bearer {KEY}"},
    timeout=60,
)
print(r.status_code)
print(r.json())
Node.js
const KEY = 'q360_live_...'; // khóa API của brand
const url = new URL('https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/100000000000000101/messages');
for (const [k, v] of Object.entries({})) url.searchParams.set(k, typeof v === 'object' ? JSON.stringify(v) : String(v));
const r = await fetch(url, {
  method: 'POST',
  headers: { Authorization: `Bearer ${KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({"msg_type":"TEXT","content":"{\"content\":\"Xin chào, mời hợp tác\"}"}),
});
console.log(r.status, await r.json());
PHP
<?php
$key = 'q360_live_...'; // khóa API của brand
$url = 'https://partner.quantri360.com/v1/tiktok/affiliate_seller/202412/conversations/100000000000000101/messages' . '?' . http_build_query([]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key, 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"msg_type":"TEXT","content":"{\"content\":\"Xin chào, mời hợp tác\"}"}');
$res = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $status, "\n", $res;

Response

Response fields (as returned by TikTok Shop)

NameTypeSampleDescription
codeint0Mã kết quả; 0 là thành công.
messagestringSuccessThông báo kết quả.
request_idstringDEMO_AFFILIATE_REQUESTMã truy vết yêu cầu.
dataobjectDữ liệu phản hồi.
message_idstring100000000000000101Mã tin nhắn.

Response sample

{
  "code": 0,
  "message": "Success",
  "request_id": "DEMO_AFFILIATE_REQUEST",
  "data": {
    "message_id": "100000000000000101"
  }
}

Get started

  1. Sign up for Partner
  2. Enable a data type of the Affiliate group on the platform page
  3. Create an API key (tick the TikTok Shop channel)
  4. Call it as in the examples above