Content Management

Delete video

Delete videos

Use the following API call to delete videos from your TargetVideo library. To delete several at once, pass their IDs as a comma-separated list.

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

Parameter name

Description

Required

ids (string)

Comma-separated video IDs, e.g. 12345,12346. An array (ids[]) is also accepted.

yes

partner_id (integer)

Website ID in TargetVideo CMS

yes

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

Examples

PHP

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.target-video.com/apiv3/video/delete.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('data[Video][ids]' => 'VIDEO_ID','data[Video][partner_id]' => 'PARTNER_ID'),
  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("data[Video][ids]", "VIDEO_ID")
  .addFormDataPart("data[Video][partner_id]", "PARTNER_ID")
  .build();
Request request = new Request.Builder()
  .url("https://api.target-video.com/apiv3/video/delete.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/delete.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=\"data[Video][ids]\"\r\n\r\nVIDEO_ID\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"data[Video][partner_id]\"\r\n\r\nPARTNER_ID\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=data[Video][ids];')

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

dataList.append("VIDEO_ID")
dataList.append('--' + boundary)
dataList.append('Content-Disposition: form-data; name=data[Video][partner_id];')

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

dataList.append("PARTNER_ID")
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/delete.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/delete.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 = [['data[Video][ids]', 'VIDEO_ID'],['data[Video][partner_id]', 'PARTNER_ID']]
request.set_form form_data, 'multipart/form-data'
response = https.request(request)
puts response.read_body

On success the response contains "status": true and the message Video(s) deleted. Each ID must belong to a video in a website you manage; otherwise the request fails with HTTP 400.

Delete video · TargetVideo Developer Docs