VI | EN
Message us on Messenger
Developer resources

Upload File Init — TikTok Shop API

tiktok.open.202512.file.init · 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.open.202512.file.init

POST/open/202512/file/initVia 360: POST https://partner.quantri360.com/v1/tiktok/open/202512/file/init
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

Khởi tạo phiên tải video, sau đó tải tệp tới upload_url. Tệp tối đa 5 MiB (5.242.880 byte) tải một phần với total_chunk_count = 1; tệp lớn hơn tải nhiều phần. Dùng ResourceId sau khi tải để gắn tài nguyên vào target_path.

  • Gọi qua /v1/tiktok/open/202512/file/init 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 _basic. Khởi tạo phiên tải video, sau đó tải tệp tới upload_url. Tệp tối đa 5 MiB (5.242.880 byte) tải một phần với total_chunk_count = 1; tệp lớn hơn tải nhiều phần. Dùng ResourceId sau khi tải để gắn tài nguyên vào target_path.
  • HTTP 200 vẫn có thể có lỗi nghiệp vụ; kiểm code trước khi dùng kết quả.
  • Khởi tạo phiên chưa hoàn tất tải tệp; phải tải tới upload_url rồi dùng ResourceId cho thao tác gắn tài nguyên.

Request

Endpoint

POST https://partner.quantri360.com/v1/tiktok/open/202512/file/init

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
category_asset_cipherquerystringNoMinh họaMã tài sản danh mục đã được cấp quyền, dùng khi truyền thông tin gian hàng xuyên biên giới.
file_namebodystringYesvideo-minh-hoa.mp4Tệp tên.
file_typebodystringYesvideoLoại tệp; hiện chỉ hỗ trợ video.
file_sizebodyintYes1048576Kích thước tệp tính bằng byte.
total_chunk_countbodyintYes1Số phần tải lên, lớn hơn 0; tệp không quá 5 MiB (5.242.880 byte) phải đặt 1.
target_pathbodystringYes/open/202512/file/initĐường dẫn thao tác dùng để gắn tài nguyên video sau khi tải.

Request examples

curl -s -X POST "https://partner.quantri360.com/v1/tiktok/open/202512/file/init?category_asset_cipher=Minh%20h%E1%BB%8Da" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_name":"video-minh-hoa.mp4","file_type":"video","file_size":1048576,"total_chunk_count":1,"target_path":"[POST]/affiliate_seller/202501/images/upload"}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/tiktok/open/202512/file/init",
    params={
        "category_asset_cipher": "Minh họa"
    },
    json={
        "file_name": "video-minh-hoa.mp4",
        "file_type": "video",
        "file_size": 1048576,
        "total_chunk_count": 1,
        "target_path": "[POST]/affiliate_seller/202501/images/upload"
    },
    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/open/202512/file/init');
for (const [k, v] of Object.entries({"category_asset_cipher":"Minh họa"})) 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({"file_name":"video-minh-hoa.mp4","file_type":"video","file_size":1048576,"total_chunk_count":1,"target_path":"[POST]/affiliate_seller/202501/images/upload"}),
});
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/open/202512/file/init' . '?' . http_build_query(['category_asset_cipher' => 'Minh họa']);
$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, '{"file_name":"video-minh-hoa.mp4","file_type":"video","file_size":1048576,"total_chunk_count":1,"target_path":"[POST]/affiliate_seller/202501/images/upload"}');
$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ã. Giá trị: API.
messagestringSuccessTin nhắn. Giá trị: API.
request_idstringDEMO_REQUEST_A_01Yêu cầu mã.
dataobjectDữ liệu.
upload_urlstringTải lên url. Giá trị: URL.
upload_tokenstringTải lên con trỏ. Giá trị: URL.

Response sample

{
  "code": 0,
  "message": "Success",
  "request_id": "DEMO_REQUEST_A_01",
  "data": {
    "upload_url": "",
    "upload_token": ""
  }
}

Get started

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