Content Management

Upload video

Add a video to your library from the URL of an MP4 file.

Upload video using add method

You can upload a video and add some basic metadata for it using the add API method.

POST https://api.target-video.com/apiv3/video/add.json

Every request must send your API token in an Authorization: Bearer header — see API credentials.

Parameter name

Description

Required

partner_id (integer)

ID of the website (partner) in the TargetVideo CMS

yes

name (string)

Video title

yes

mp4 (string)

Valid URL to the MP4 file

yes

publish (string)

Publish date, in DD-MM-YYYY format

yes

description (string)

Video description

optional

tags (string)

Comma-separated video tags

optional

encode (integer)

Set to 1 to transcode the file at mp4, or 0 to play it directly from that URL (externally hosted). Default 0.

optional

image (string)

Valid URL of an image to use as the video snapshot. Only needed for a custom snapshot.

optional

copy_snapshot (integer)

Set to 1 to import the image at image into TargetVideo. Only applies when image is set.

optional

kill_date (string)

Date on which the video is unpublished, in DD-MM-YYYY format

optional

geo_on (integer)

Set to 1 to enable geo-targeting for the video. Default 0.

optional

geo (string)

Comma-separated ISO 3166-1 alpha-2 country codes, e.g. US,GB,DE.

optional

Examples

PHP

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.target-video.com/apiv3/video/add.json",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('partner_id' => '{{PARTNER_ID}}','name' => 'Crying Beagle Puppy is Too Small To Jump On Couch','mp4' => 'https://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4','description' => 'Our beagle puppy Lilly is too little to jump on the couch . She crying because she wants to sleep with our baby daughter and steal her food .','publish' => '19-02-2020','tags' => 'cute,dog,puppy','encode' => '1','image' => 'https://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4_thumb','copy_snapshot' => '1','kill_date' => '19-09-2020','geo_on' => '0','geo' => 'AF,AX,DZ'),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer YOUR_API_TOKEN"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("partner_id", "{{PARTNER_ID}}")
  .addFormDataPart("name", "Crying Beagle Puppy is Too Small To Jump On Couch")
  .addFormDataPart("mp4", "http://cdn.target-video.com/live/partners/12579/sd/540625.mp4")
  .addFormDataPart("description", "Our beagle puppy Lilly is too little to jump on the couch . She crying because she wants to sleep with our baby daughter and steal her food .")
  .addFormDataPart("publish", "19-02-2020")
  .addFormDataPart("tags", "cute,dog,puppy")
  .addFormDataPart("encode", "1")
  .addFormDataPart("image", "https://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4_thumb")
  .addFormDataPart("copy_snapshot", "1")
  .addFormDataPart("kill_date", "19-09-2020")
  .addFormDataPart("geo_on", "0")
  .addFormDataPart("geo", "AF,AX,DZ")
  .build();
Request request = new Request.Builder()
  .url("https://api.target-video.com/apiv3/video/add.json")
  .method("POST", body)
  .addHeader("Authorization", "Bearer YOUR_API_TOKEN")
  .build();
Response response = client.newCall(request).execute();

JavaScript

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.target-video.com',
  'path': '/apiv3/video/add.json',
  'headers': {
    'Authorization': 'Bearer YOUR_API_TOKEN'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"partner_id\"\r\n\r\n{{PARTNER_ID}}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nCrying Beagle Puppy is Too Small To Jump On Couch\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"mp4\"\r\n\r\nhttp://cdn.target-video.com/live/partners/12579/sd/540625.mp4\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"description\"\r\n\r\nOur beagle puppy Lilly is too little to jump on the couch . She crying because she wants to sleep with our baby daughter and steal her food .\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"publish\"\r\n\r\n19-02-2020\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"tags\"\r\n\r\ncute,dog,puppy\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"encode\"\r\n\r\n1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\nhttps://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4_thumb\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"copy_snapshot\"\r\n\r\n1\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"kill_date\"\r\n\r\n19-09-2020\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"geo_on\"\r\n\r\n0\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"geo\"\r\n\r\nAF,AX,DZ\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--";

req.setHeader('content-type', 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');

req.write(postData);

req.end();

Python

import http.client
import mimetypes
conn = http.client.HTTPSConnection("api.target-video.com")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=partner_id;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("{{PARTNER_ID}}")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=name;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("Crying Beagle Puppy is Too Small To Jump On Couch")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=mp4;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("http://cdn.target-video.com/live/partners/12579/sd/540625.mp4")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=description;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("Our beagle puppy Lilly is too little to jump on the couch . She crying because she wants to sleep with our baby daughter and steal her food .")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=publish;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("19-02-2020")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=tags;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("cute,dog,puppy")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=encode;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("1")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=image;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("https://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4_thumb")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=copy_snapshot;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("1")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=kill_date;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("19-09-2020")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=geo_on;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("0")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=geo;')

dataList.append('Content-Type: {}'.format('multipart/form-data'))
dataList.append('')

dataList.append("AF,AX,DZ")
dataList.append('--'+boundary+'--')
dataList.append('')
body = '\r\n'.join(dataList)
payload = body
headers = {
  'Authorization': 'Bearer YOUR_API_TOKEN',
  'Content-type': 'multipart/form-data; boundary={}'.format(boundary)
}
conn.request("POST", "/apiv3/video/add.json", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

Ruby

require "uri"
require "net/http"

url = URI("https://api.target-video.com/apiv3/video/add.json")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer YOUR_API_TOKEN"
form_data = [['partner_id', '{{PARTNER_ID}}'],['name', 'Crying Beagle Puppy is Too Small To Jump On Couch'],['mp4', 'http://cdn.target-video.com/live/partners/12579/sd/540625.mp4'],['description', 'Our beagle puppy Lilly is too little to jump on the couch . She crying because she wants to sleep with our baby daughter and steal her food .'],['publish', '19-02-2020'],['tags', 'cute,dog,puppy'],['encode', '1'],['image', 'https://smores-video-storage.s3.amazonaws.com/user_168900%2F1582139560371_video.mp4_thumb'],['copy_snapshot', '1'],['kill_date', '19-09-2020'],['geo_on', '0'],['geo', 'AF,AX,DZ']]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

On success the response contains "status": true, the message Video has been saved. and the new video’s id. If the video can’t be saved — for example name or mp4 is missing — the request fails with HTTP 400 and errors.validation lists each field that failed.

Upload video · TargetVideo Developer Docs