Docs
Stay tuned! We're working on awesome new functionality for our new Content Posting API to include an incredible feature: The ability to directly post videos to authorized user accounts.
Tip: You can enable email notifications to get our latest product updates.
Get Started
This guide will show you how to use our Content Posting API to upload videos to TikTok.
Prerequisites
To successfully complete this tutorial, you will need the following:
- A valid video:
- Ensure you have a video file in one of the supported formats, such as MP4 + H.264, stored on your local machine.
- Alternatively, you can provide a URL of a video from your verified domain or URL prefix. Learn how to verify your domain or URL prefix.
- Learn more about video restrictions.
- A registered app on the TikTok for Developers website.
- Grant appropriate authorization scope for
Upload Video
endpoint:
Approval and authorization of the video.upload
scope. Learn more about scopes.
- Your app must be approved for the
video.upload
scope. - The target TikTok user must have authorized your app for the
video.upload
scope.
- The access token and open ID of the TikTok user who authorized your app. Learn how to obtain the access token and open ID.
Upload a video for a TikTok user using Upload Video endpoint
This section demonstrates how to successfully send a video to TikTok, ready for the user to review and post.
User notified of video upload | User reviews and posts video |
- To initiate video upload on TikTok's servers, you must invoke the Content Posting API - Video Upload endpoint. You have the following two options:
- If you have the video file locally, set the source parameter to
FILE_UPLOAD
in your request. - If the video is hosted on a URL, set the source parameter to
PULL_FROM_URL
.
Examples
Example using source=FILE_UPLOAD
:
Request:
curl --location 'https://open.tiktokapis.com/v2/post/publish/inbox/video/init/' \
--header 'Authorization: Bearer exampleUserAccessToken' \
--header 'Content-Type: application/json' \
--data '{
"source_info": {
"source": "FILE_UPLOAD",
"video_size": exampleVideoSize,
"chunk_size" : exampleVideoSize,
"total_chunk_count": 1
}
}'
Response:
200 OK
{
"data": {
"publish_id": "v_inbox_file~v2.123456789",
"upload_url": "https://open-upload.tiktokapis.com/video/?upload_id=67890&upload_token=Xza123"
},
"error": {
"code": "ok",
"message": "",
"log_id": "202210112248442CB9319E1FB30C1073F3"
}
}
Example using source=PULL_FROM_URL
:
Request:
curl --location 'https://open.tiktokapis.com/v2/post/publish/inbox/video/init/' \
--header 'Authorization: Bearer exampleUserAccessToken' \
--header 'Content-Type: application/json' \
--data '{
"source_info": {
"source": "PULL_FROM_URL",
"video_url": "https://example.verified.domain.com/example_video.mp4",
}
}'
Response:
200 OK
{
"data": {
"publish_id": "v_inbox_url~v2.123456789"
},
"error": {
"code": "ok",
"message": "",
"log_id": "202210112248442CB9319E1FB30C1073F4"
}
}
- If you are using
source=FILE_UPLOAD
: - Extract the
upload_url
andpublish_id
from the response data. - Send the video from your local filesystem to the extracted
upload_url
using a PUT request. The video processing will occur asynchronously once the upload is complete.
curl --location --request PUT 'https://open-upload.tiktokapis.com/video/?upload_id=67890&upload_token=Xza123' \
--header 'Content-Range: bytes 0-30567099/30567100' \
--header 'Content-Type: video/mp4' \
--data '@/path/to/file/example.mp4'
- With the
publish_id
returned earlier, check for status updates using the Get Video Status endpoint.
curl --location 'https://open.tiktokapis.com/v2/post/publish/status/fetch/' \
--header 'Authorization: Bearer exampleUserAccessToken' \
--header 'Content-Type: application/json; charset=UTF-8' \
--data '{
"publish_id": "v_inbox_file~v2.123456789"
}'