# 1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/ POST https://graph.facebook.com/v2/post/publish/video/init/ Content-Type: application/json Reference: https://docs.deao.dev/cloudflare/social-media-posting/tik-tok/video/1-initialize-upload-https-open-tiktokapis-com-v-2-post-publish-video-init ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: collection version: 1.0.0 paths: /v2/post/publish/video/init/: post: operationId: >- 1-initialize-upload-https-open-tiktokapis-com-v-2-post-publish-video-init summary: >- 1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/ tags: - >- subpackage_socialMediaPosting.subpackage_socialMediaPosting/tikTok.subpackage_socialMediaPosting/tikTok/video responses: '200': description: OK content: application/json: schema: $ref: >- #/components/schemas/Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_Response_200 requestBody: content: application/json: schema: type: string servers: - url: https://graph.facebook.com - url: https://www.youtube.com - url: https://youtube-video-summarizer-gpt-ai.p.rapidapi.com - url: https://api.cloudflare.com - url: https://dev-musiccast.odoo.com - url: https://api.search.brave.com - url: https://og-image-generator-dev.deao.workers.dev - url: https://musiccast.odoo.com - url: https://m.musicca.st - url: https://api.stripe.com - url: https://api.kie.ai - url: https://api.pexels.com - url: https://api.shotstack.io - url: https://oauth2.googleapis.com - url: https://www.googleapis.com - url: https://api.linkedin.com - url: https://www.linkedin.com - url: https://rupload.facebook.com - url: https://api.x.com - url: https://open.tiktokapis.com - url: https://open-upload-sg.tiktokapis.com - url: https://social-media-posting-dev.deao.workers.dev components: schemas: V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaData: type: object properties: publish_id: type: string upload_url: type: string format: uri required: - publish_id - upload_url title: V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaData V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaError: type: object properties: code: type: string log_id: type: string message: type: string required: - code - log_id - message title: V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaError 'Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_Response_200': type: object properties: data: $ref: >- #/components/schemas/V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaData error: $ref: >- #/components/schemas/V2PostPublishVideoInitPostResponsesContentApplicationJsonSchemaError required: - data - error title: >- Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_Response_200 ``` ## SDK Code Examples ```python Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example import requests url = "https://graph.facebook.com/v2/post/publish/video/init/" payload = "{ \"post_info\": { \"title\": \"New Video\", \"privacy_level\": \"SELF_ONLY\", \"disable_duet\": false, \"disable_comment\": false, \"disable_stitch\": false, \"video_cover_timestamp_ms\": 1000 }, \"source_info\": { \"source\": \"FILE_UPLOAD\", \"video_size\": 295424642, \"chunk_size\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB \"total_chunk_count\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size. } }" headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example const url = 'https://graph.facebook.com/v2/post/publish/video/init/'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '"{\n \"post_info\": {\n \"title\": \"New Video\",\n \"privacy_level\": \"SELF_ONLY\",\n \"disable_duet\": false,\n \"disable_comment\": false,\n \"disable_stitch\": false,\n \"video_cover_timestamp_ms\": 1000\n },\n \"source_info\": {\n \"source\": \"FILE_UPLOAD\",\n \"video_size\": 295424642,\n \"chunk_size\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\n \"total_chunk_count\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\n }\n}"' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://graph.facebook.com/v2/post/publish/video/init/" payload := strings.NewReader("\"{\\n \\\"post_info\\\": {\\n \\\"title\\\": \\\"New Video\\\",\\n \\\"privacy_level\\\": \\\"SELF_ONLY\\\",\\n \\\"disable_duet\\\": false,\\n \\\"disable_comment\\\": false,\\n \\\"disable_stitch\\\": false,\\n \\\"video_cover_timestamp_ms\\\": 1000\\n },\\n \\\"source_info\\\": {\\n \\\"source\\\": \\\"FILE_UPLOAD\\\",\\n \\\"video_size\\\": 295424642,\\n \\\"chunk_size\\\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\\n \\\"total_chunk_count\\\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\\n }\\n}\"") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example require 'uri' require 'net/http' url = URI("https://graph.facebook.com/v2/post/publish/video/init/") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Content-Type"] = 'application/json' request.body = "\"{\\n \\\"post_info\\\": {\\n \\\"title\\\": \\\"New Video\\\",\\n \\\"privacy_level\\\": \\\"SELF_ONLY\\\",\\n \\\"disable_duet\\\": false,\\n \\\"disable_comment\\\": false,\\n \\\"disable_stitch\\\": false,\\n \\\"video_cover_timestamp_ms\\\": 1000\\n },\\n \\\"source_info\\\": {\\n \\\"source\\\": \\\"FILE_UPLOAD\\\",\\n \\\"video_size\\\": 295424642,\\n \\\"chunk_size\\\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\\n \\\"total_chunk_count\\\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\\n }\\n}\"" response = http.request(request) puts response.read_body ``` ```java Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://graph.facebook.com/v2/post/publish/video/init/") .header("Content-Type", "application/json") .body("\"{\\n \\\"post_info\\\": {\\n \\\"title\\\": \\\"New Video\\\",\\n \\\"privacy_level\\\": \\\"SELF_ONLY\\\",\\n \\\"disable_duet\\\": false,\\n \\\"disable_comment\\\": false,\\n \\\"disable_stitch\\\": false,\\n \\\"video_cover_timestamp_ms\\\": 1000\\n },\\n \\\"source_info\\\": {\\n \\\"source\\\": \\\"FILE_UPLOAD\\\",\\n \\\"video_size\\\": 295424642,\\n \\\"chunk_size\\\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\\n \\\"total_chunk_count\\\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\\n }\\n}\"") .asString(); ``` ```php Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example request('POST', 'https://graph.facebook.com/v2/post/publish/video/init/', [ 'body' => '"{\\n \\"post_info\\": {\\n \\"title\\": \\"New Video\\",\\n \\"privacy_level\\": \\"SELF_ONLY\\",\\n \\"disable_duet\\": false,\\n \\"disable_comment\\": false,\\n \\"disable_stitch\\": false,\\n \\"video_cover_timestamp_ms\\": 1000\\n },\\n \\"source_info\\": {\\n \\"source\\": \\"FILE_UPLOAD\\",\\n \\"video_size\\": 295424642,\\n \\"chunk_size\\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\\n \\"total_chunk_count\\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\\n }\\n}"', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example using RestSharp; var client = new RestClient("https://graph.facebook.com/v2/post/publish/video/init/"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "\"{\\n \\\"post_info\\\": {\\n \\\"title\\\": \\\"New Video\\\",\\n \\\"privacy_level\\\": \\\"SELF_ONLY\\\",\\n \\\"disable_duet\\\": false,\\n \\\"disable_comment\\\": false,\\n \\\"disable_stitch\\\": false,\\n \\\"video_cover_timestamp_ms\\\": 1000\\n },\\n \\\"source_info\\\": {\\n \\\"source\\\": \\\"FILE_UPLOAD\\\",\\n \\\"video_size\\\": 295424642,\\n \\\"chunk_size\\\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB\\n \\\"total_chunk_count\\\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size.\\n }\\n}\"", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Social Media Posting_TikTok_Video_1. Initialize Upload: https://open.tiktokapis.com/v2/post/publish/video/init/_example import Foundation let headers = ["Content-Type": "application/json"] let parameters = "{ \"post_info\": { \"title\": \"New Video\", \"privacy_level\": \"SELF_ONLY\", \"disable_duet\": false, \"disable_comment\": false, \"disable_stitch\": false, \"video_cover_timestamp_ms\": 1000 }, \"source_info\": { \"source\": \"FILE_UPLOAD\", \"video_size\": 295424642, \"chunk_size\": 67108864, //Each one is 64MB/MiB, the last one can be up to 128MB \"total_chunk_count\": 4 //The last shunk is not counted (it is joined to the penultimate one) unless it is the same size. } }" as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://graph.facebook.com/v2/post/publish/video/init/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```