DELETE v4/packages/:pkg_sku/assets - Delete

Remove asset/sku from a specific package. You can only remove assets from a package in which the requesting API key created the package.

Supported Roles and Authentication Protocols

Type Supported Values
Authentication Protocols API Key
Valid for Roles System to System

API Request

HTTP Verbs and URLs

DELETE v4/packages/:pkg_sku/assets
  • :pkg_sku is the SKU generated by VitalSource at creation and returned in the response

Request Headers

X-VitalSource-API-Key: ABCDEFGHIJKLMNOP
Content-Type: application/json

Request Body

Request

{ 
"products": ["L-999-70461"]
}

Element Descriptions

Element Description Required
products {sku} A list of assets or sku identifiers that when provided are removed from a specific package. This immediately removes access for a specific title within a package for all users Yes

Request Response

curl -X DELETE "X-VitalSource-API-Key: ABCDEFGHIJKLMNOP" -H "Content-Type: application/json" -d '{ 
"products": ["1234]
}' "https://api.vitalsource.com/v4/packages/:id/assets"
HTTP Code: 200
{
"removed_count": 1
}
require 'uri'
require 'net/http'

url = URI("https://api.vitalsource.com/v4/packages/:id/assets")

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

request = Net::HTTP::Delete.new(url)
request["x-vitalsource-api-key"] = 'ABCDEFGHIJKLMNOP'
request["content-type"] = 'application/json'
request.body = "{ \n \"products\": [\"L-999-70461\"]\n}"

response = http.request(request)
puts response.read_body
<?php

client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{
"products": ["L-999-70461"]
}');

$request->setRequestUrl('https://api.vitalsource.com/v4/packages/:id/assets');
$request->setRequestMethod('DELETE');
$request->setBody($body);

$request->setHeaders(array(
'content-type' => 'application/json',
'x-vitalsource-api-key' => 'ABCDEFGHIJKLMNOP',
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody(); ?php>
var client = new RestClient("https://api.vitalsource.com/v4/packages/:id/assets");
var request = new RestRequest(Method.DELETE);
request.AddHeader("content-type", "application/json");
request.AddHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP");
request.AddParameter("application/json", "{ \n \"products\": [\"L-999-70461\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var http = require("https");

var options = {
"method": "DELETE",
"hostname": "api.vitalsource.com",
"port": null,
"path": "/v4/packages/:id/assets",
"x-vitalsource-api-key": "ABCDEFGHIJKLMNOP",
"content-type": "application/json",
}
};

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

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

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

req.write(JSON.stringify({ products: [ 'L-999-70461' ] }));
req.end();
import http.client

conn = http.client.HTTPSConnection("api-dev.vitalsource.com")

payload = "{ \n \"products\": [\"L-999-70461\"]\n}"

headers = {
'x-vitalsource-api-key': "ABCDEFGHIJKLMNOP",
'content-type': "application/json",
}

conn.request("DELETE", "/v4/packages/:id/assets", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \n \"products\": [\"L-999-70461\"]\n}");
Request request = new Request.Builder()
.url("https://api.vitalsource.com/v4/packages/:id/assets")
.delete(body)
.addHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP")
.addHeader("content-type", "application/json")
.build();

Response response = client.newCall(request).execute();
 

Element Descriptions

Element Description
removed_count Number of items successfully removed from the package.

Specific error codes for this endpoint

403: Permission Denied
404: Package not found

See our full list of error codes and messages.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.