Add Assets to Library

Adds one or more assets to a specified library.

Endpoint

PATCH /libraries/{library_id}/assets

Path Parameters

NameTypeRequiredDescription
library_idStringYesThe unique identifier of the library to update.

Request Parameters

Pass the following request body parameters:

NameData TypeRequiredDescription
asset_idsArrayYesA list of asset IDs to add to the library.

Example Request

{
  "asset_ids": ["789012", "345678"]
}

Response

A successful request returns:

NameData TypeDescription
@idStringRelative path to retrieve this resource.
@typeStringReturns Library.
idStringSystem-defined identifier for the library.
descStringLibrary name.
owner_nameStringEmail associated with the library owner.
library_typeStringIndicates owner if you created this library.
assetsArrayList of asset IDs added to the library.

Sample Code

import json
import requests
from api_auth import APICredentials, APIParams

class Add_Assets_To_Library:
    def __init__(self, library_id, asset_ids):
        self.host = "https://services.uplynk.com"
        self.library_id = library_id
        self.asset_ids = asset_ids
    
    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_ids": self.asset_ids}
        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", ["789012", "345678"]).run()

Sample Response

{
  "@id": "/api/v4/libraries/8b69f969c65e481385281331520cf1e2",
  "@type": "Library",
  "id": "8b69f969c65e481385281331520cf1e2",
  "desc": "Marketing Library",
  "owner_name": "[email protected]",
  "library_type": "owner",
  "assets": ["789012", "345678"]
}