VI | EN
Message us on Messenger
Developer resources

Upload a file — TikTok Business API

Upload a file · 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.

Upload a file

POST/file/temporarily/upload/Via 360: POST https://partner.quantri360.com/v1/tiktok_business/file/temporarily/upload/
Write endpoint — changes data on TikTok Business. The key must be created with "Allow write API calls" ticked, otherwise you get 403 write_not_allowed. Every call is logged.
Description

Use this endpoint to upload a file. The transfer speed is limited by your network bandwidth. The maximum size of a file that you can upload is 100 MB.

After you upload a file to TikTok’s file repository, a file_id will be returned in the response. You can use the file_id to retrieve the file in the repository and transfer it to the Asset Library.

> Note

> Once a file is uploaded to the file repository, it is kept for 24 hours, after which it will expire. If the file you want to use in your ads expires, you need to re-upload the file to the file repository.

Request

Endpoint

POST https://partner.quantri360.com/v1/tiktok_business/file/temporarily/upload/

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_idquerystring7000000000000000001Tài sản TikTok Business đã kết nối — "Mã tài sản" ở trang Nền tảng hoặc GET /v1/platforms (tài khoản quảng cáo cho Marketing API, tài khoản TikTok cho Organic / Messaging). Có thể bỏ khi chỉ kết nối một tài sản.

Request parameters

NameInTypeRequiredSampleDescription
upload_typebodystringYesThe upload type. Enum values:FILE, URL
content_typebodystringYesThe file type. Enum values:image, music, video, playable
filebodyfileNoThe file that you want to upload. Required when upload_typeis set toFILE. The maximum size of a file that you can upload is 100 MB. Note: To upload a customized music file that can be used in Carousel Ads, the file that you specify through this field should meet the following specifications requirements: - File Type: MP3. - File Size: no greater than 10 MB.
urlbodystringNoThe URL of the file that you want to upload, in the format of “ Required when upload_type is URL.
signaturebodystringNoThe MD5 value of the file, used as a checksum to check data integrity by the server side. Required when upload_type is FILE.
namebodystringNoThe file name. Character limit is 100. Note: Each word in Chinese or Japanese counts as three characters, while each letter in English counts as one character.

Request examples

curl -s -X POST "https://partner.quantri360.com/v1/tiktok_business/file/temporarily/upload/" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"upload_type":"","content_type":""}'
Python
import requests

KEY = "q360_live_..."  # khóa API của brand
r = requests.post(
    "https://partner.quantri360.com/v1/tiktok_business/file/temporarily/upload/",
    params={},
    json={
        "upload_type": "",
        "content_type": ""
    },
    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_business/file/temporarily/upload/');
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({"upload_type":"","content_type":""}),
});
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_business/file/temporarily/upload/' . '?' . 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, '{"upload_type":"","content_type":""}');
$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 Business)

NameTypeSampleDescription
codenumberThe response code. For the complete list of response codes and descriptions, see Appendix - Return Codes.
messagestringThe response message. For details, see Appendix - Return Codes.
dataobjectThe returned data.
file_idstringThe ID of the file that you have uploaded. You can use this ID to upload the file from the file library to the creatives library. It is valid for 24 hours.
signaturestringThe MD5 value of the file.
file_sizenumberThe file size in bytes.
create_timestringThe time when the file was uploaded in the format of YYYY-MM-DD HH:MM:SS(UTC+0). Example: 2020-06-10 07:39:14.
request_idstringThe unique ID of the request.

Response sample

HTTPS/1.1 200 OK
{
    "message": "OK",
    "code": 0,
    "data": {
        "file_id": "264c544d8d383388383c8a8129b33a74_1609142644",
        "signature": "264c544d8d383388383c8a8129b33a74",
        "create_time": "2020-12-28 08:04:04",
        "file_size": 1645516
    },
    "request_id": "202012280804020101151761271A085384"
}
(/code);

Get started

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