POST v4/packages - Create

Use this API to create a Package product with a collection of Assets/SKUs. This is to be used if you want to group multiple titles into a single SKU to allow for redemptions of a package of titles or resources for a user.

Supported Roles and Authentication Protocols

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

API Request

HTTP Verbs and URLs

POST v4/packages

Request Headers

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

Request Body

Request

{ 
    "sku": "TEST-123454",
"name":"Package Name", "description":"", "products": ["1234", "5678"], "library_id":"1", "download_license": { "type":"", "num_days":"", "expiration_date":"2017-01-01" }, "online_license": { "type":"", "num_days":"", "expiration_date":"2017-01-01" }, "list_price": 19.99, }

Element Descriptions

Element Description Required
sku Populate to create a custom SKU for the package. If this is not included a SKU will be automatically created and returned in the response. This will be used for creating/redeeming codes to provide access to packages and content to users. No
name The name of the package Yes
description Optional package description to display to end users No
products {sku} A list of assets or sku identifiers that are needed to create the package. This can be left blank but will create an empty package to be updated later No
library_id The specific Library set up within VitalSource Manage to specify where the package will live. This must be a LibraryID that was created by the requesting companies API key. Yes
download_license/online_license Specific elements to specify the license length and type for downloadable and online clients. Must set a specific value Yes
 type Set value for type of license. Options are numdays, absdate, perpetual  Yes
num_days Number of days from redemption that access is granted Only if type=numdays
expiration_date The date in YYYY-MM-DD for the package expiration Only if type=absdate
list_price The price for the package if necessary No

Request Response

curl -X POST -H "X-VitalSource-API-Key: ABCDEFGHIJKLMNOP" -H "Content-Type: application/json" -d '{
    "name":"Sample Package",
    "products": [ ":sku" ],
    "description": "Sample description goes here!",
    "library_id":":id",
    "download_license": {
        "type":"absdate",
        "expiration_date":"2017-01-25"
    },
    "online_license": {
        "type":"numdays",
        "num_days":"25"
    },
    "list_price": 19.99
}' "https://api.vitalsource.com/v4/packages"
HTTP Code: 200
{
 "sku": "RACD4MGK32C8",
 "name": "Sample Package",
 "description": "Sample description goes here!",
 "publisher": "Company Name",
 "list_price": 19.99,
 "download_license": {
    "details": "Expires 1 days after registration",
    "duration": "1 days"
 },
 "online_license": {
    "details": "Expires 1 days after registration",
    "duration": "1 days"
 },
 "tags": [],
 "created_on": "2016-03-16T18:49:35Z",
 "updated_on": "2016-03-16T18:49:35Z",
 "products": [
 {
    "isbn": "L-999-70461",
    "vbid": "L-999-70461",
    "fpid": null,
    "isbn13": null,
    "description": "In Dickens's traditional favorite Christmas story, miser Ebenezer Scrooge, who despises Christmas and all who revel in its cheer, is forced to take a hard look at his life of selfishness and greed. On Christmas Eve, the ghost of his business partner Jacob Marley and the Spirits of Christmas Past, Present, and Future break Scrooge's calloused heart and redeem him",
    "publication_date": "1843",
    "author": "Charles Dickens",
    "title": "A Christmas Carol",
    "sort_title": "Christmas Carol",
    "icon_url": "http://covers.vitalbook.com/vbid/L-999-70461/width/120",
    "sampleable": true
 }
 ]
} 
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Post.new(url)
request["x-vitalsource-api-key"] = 'ABCDEFGHIJKLMNOP'
request["content-type"] = 'application/json'
request.body = "{\n    \"name\":\"Sample Package\",\n    \"description\": \"Sample description goes here!\",\n    \"products\": [ \"L-999-70461\" ],\n    \"library_id\":\"2156\",\n    \"download_license\": {\n        \"type\":\"absdate\",\n        \"expiration_date\":\"2017-01-01\"\n    },\n    \"online_license\": {\n        \"type\":\"numdays\",\n        \"num_days\":\"1\"\n    },\n    \"list_price\": 19.99,\n    \"tags\": [\"ENG101\",\"Composition\"]\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('{
    "name":"Sample Package",
    "description": "Sample description goes here!",
    "products": [ "L-999-70461" ],
    "library_id":"2156",
    "download_license": {
        "type":"absdate",
        "expiration_date":"2017-01-01"
    },
    "online_license": {
        "type":"numdays",
        "num_days":"1"
    },
    "list_price": 19.99,
    "tags": ["ENG101","Composition"]
}');

$request->setRequestUrl('https://api.vitalsource.com/v4/packages');
$request->setRequestMethod('POST');
$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");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP");
request.AddParameter("application/json", "{\n    \"name\":\"Sample Package\",\n    \"description\": \"Sample description goes here!\",\n    \"products\": [ \"L-999-70461\" ],\n    \"library_id\":\"2156\",\n    \"download_license\": {\n        \"type\":\"absdate\",\n        \"expiration_date\":\"2017-01-01\"\n    },\n    \"online_license\": {\n        \"type\":\"numdays\",\n        \"num_days\":\"1\"\n    },\n    \"list_price\": 19.99,\n    \"tags\": [\"ENG101\",\"Composition\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var http = require("https");

var options = {
  "method": "POST",
  "hostname": "api.vitalsource.com",
  "port": null,
  "path": "/v4/packages",
  "headers": {
    "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({ name: 'Sample Package',
  description: 'Sample description goes here!',
  products: [ 'L-999-70461' ],
  library_id: '2156',
  download_license: { type: 'absdate', expiration_date: '2017-01-01' },
  online_license: { type: 'numdays', num_days: '1' },
  list_price: 19.99,
  tags: [ 'ENG101', 'Composition' ] }));
req.end();
import http.client

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

payload = "{\n    \"name\":\"Sample Package\",\n    \"description\": \"Sample description goes here!\",\n    \"products\": [ \"L-999-70461\" ],\n    \"library_id\":\"2156\",\n    \"download_license\": {\n        \"type\":\"absdate\",\n        \"expiration_date\":\"2017-01-01\"\n    },\n    \"online_license\": {\n        \"type\":\"numdays\",\n        \"num_days\":\"1\"\n    },\n    \"list_price\": 19.99,\n    \"tags\": [\"ENG101\",\"Composition\"]\n}"

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

conn.request("POST", "/v4/packages", 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    \"name\":\"Sample Package\",\n    \"description\": \"Sample description goes here!\",\n    \"products\": [ \"L-999-70461\" ],\n    \"library_id\":\"2156\",\n    \"download_license\": {\n        \"type\":\"absdate\",\n        \"expiration_date\":\"2017-01-01\"\n    },\n    \"online_license\": {\n        \"type\":\"numdays\",\n        \"num_days\":\"1\"\n    },\n    \"list_price\": 19.99,\n    \"tags\": [\"ENG101\",\"Composition\"]\n}");
Request request = new Request.Builder()
  .url("https://api.vitalsource.com/v4/packages")
  .post(body)
  .addHeader("x-vitalsource-api-key", "ABCDEFGHIJKLMNOP")
  .addHeader("content-type", "application/json")
  .build();

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

Element Descriptions

Element Description
sku The auto-generated SKU for the new package
name The name of the package
description Package description to display to end users
Publisher Name of the company who created the package
list_price The price for the package if necessary
library_id The specific Library set up within Connect to specific where the library where the package will live. This must be a LibraryID that was created by the requesting companies API key.
download_license/online_license Specific elements to specific the license length and type for downloadable and online clients. Must set a specific value
details Text describing license rules set
duration Number of days of num_days was used, otherwise null
tags An array of tags used to query and identify the package in more detail (could be course code, etc)
created_on Date the package was created
updated_on Date the package was last updated this includes meta data updates or items being added to a package
products {sku} A list of assets or sku identifiers and meta data about the items of a package

 

Specific error codes for this endpoint

403: Permission Denied. Your API Key must have publisher permissions to perform this request. Contact your rep for assistance.
422: Invalid SKU(s) (<sku-list>)
422: Name can't be blank
422: Sku can't be blank
422: License rule can't be blank
422: Online license rule can't be blank
422: Library is not acceptable. Log-in to VitalSource Manage to create/find your Library ID

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.