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
| Name | In | Type | Sample | Description |
|---|---|---|---|---|
| Authorization | header | header | Bearer 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_id | query | string | 100001 | Gian 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
| Name | In | Type | Required | Sample | Description |
|---|---|---|---|---|---|
| category_asset_cipher | query | string | No | Minh họa | Mã 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_name | body | string | Yes | video-minh-hoa.mp4 | Tệp tên. |
| file_type | body | string | Yes | video | Loại tệp; hiện chỉ hỗ trợ video. |
| file_size | body | int | Yes | 1048576 | Kích thước tệp tính bằng byte. |
| total_chunk_count | body | int | Yes | 1 | Số 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_path | body | string | Yes | /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)
| Name | Type | Sample | Description |
|---|---|---|---|
| code | int | 0 | Mã. Giá trị: API. |
| message | string | Success | Tin nhắn. Giá trị: API. |
| request_id | string | DEMO_REQUEST_A_01 | Yêu cầu mã. |
| data | object | Dữ liệu. | |
| upload_url | string | Tải lên url. Giá trị: URL. | |
| upload_token | string | Tả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
- Sign up for Partner
- Enable a data type of the Basic group on the platform page
- Create an API key (tick the TikTok Shop channel)
- Call it as in the examples above