Adds one or more assets to a specified library.
Endpoint
PATCH /libraries/{library_id}/assets
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
library_id | String | Yes | The unique identifier of the library to update. |
Request Parameters
Pass the following request body parameters:
| Name | Data Type | Required | Description |
|---|---|---|---|
asset_id | String | Yes* | ID of asset to add to the library. |
asset_ids | Array | Yes* | A list of asset IDs to add to the library. |
* Provide either asset_id or asset_ids, not both.
Example Request
{
"asset_id": "7a08bca2"
}{
"asset_ids": ["7a08bca2", "41ee4f5a"]
}Response
A successful request returns:
| Name | Data Type | Description |
|---|---|---|
@id | String | Relative path to retrieve this resource. |
@type | String | Returns Library. |
id | String | System-defined identifier for the library. |
desc | String | Library name. |
allow_copy | Bool | Indicates if assets can be copied from this library. |
is_ad | Bool | Indicates if assets in the library are used as ads. |
created | String | ISO-8601. The library creation timestamp. |
Sample Code
import json
import requests
from api_auth import APICredentials, APIParams
class Add_Assets_To_Library:
def __init__(self, library_id, asset_id):
self.host = "https://services.uplynk.com"
self.library_id = library_id
self.asset_id = asset_id
def run(self):
self._add_assets_to_library()
def _add_assets_to_library(self):
url = f"{self.host}/api/v4/libraries/{self.library_id}/assets"
payload = {"asset_id": self.asset_id}
headers = {"Content-Type": "application/json"}
response = requests.patch(
url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers
)
print(response.json())
Add_Assets_To_Library("8b69f969c65e481385281331520cf1e2", "7a08bca2").run()Sample Response
{
"@id": "/api/v4/libraries/8b69f969c65e481385281331520cf1e2/assets",
"@type": "Library",
"allow_copy": false,
"created": "2018-05-24T18:24:06.131Z",
"desc": "Marketing Library",
"id": "8b69f969c65e481385281331520cf1e2",
"is_ad": false
}