Creative Asset Library beta

https://d3a0d0y2hgofx6.cloudfront.net/openapi/en-us/creative-asset-library/creative-asset-library-openapi.yaml

Advertisers can use creative assets to store, organize and reuse brand content, such as logos, images, etc. Stored content can be used for Amazon Ads and on Amazon shopping pages. Creative assets enables brands to provide a consistent shopping experience by easily applying brand content across Amazon.

class ad_api.api.CreativeAssets(account='default', marketplace: Marketplaces = Marketplaces.EU, credentials=None, proxies=None, verify=True, timeout=None, debug=False, access_token=None)
search_assets(body: dict, str, file) ApiResponse

Search the creative asset library.

body: | REQUIRED {‘description’: ‘A caSearchRequestCommon}’

text | string | The text used for searching assets, it matches asset name, asset name prefix, tags and ASINs associated with the assets
filterCriteria Optional this is used to filter results, we support two types of filters, valueFilter and rangeFilter
valueFilters | list | Filter for certain values of asset attributes
values | list |
valueField | string | [ TAG, ASIN, CAMPAIGN_NAME, CAMPAIGN_ID, PROGRAM, ASSET_TYPE, ASSET_SUB_TYPE, APPROVED_AD_POLICY, ASSET_EXTENSION ]
rangeFilters
range | list | Filter assets which have certain ranges of asset attributes. For example, filter assets which have file size in the range of [10,20] or [40,50].
start | string |
end | string |
sortCriteria Optional this is used to get sorted results
field | string | Enum [ CREATED_TIME, SIZE, NAME, IMAGE_HEIGHT, IMAGE_WIDTH, EXTENSION ]
order | string | Enum [ ASC, DESC ]
pageCriteria Optional this is used for pagination when searching for the first page, no need to put anything, otherwise, use the token returned from previous search call
identifier | dict |
pageNumber | int |
token | string |
size | int | default: 25 minimum: 1 maximum: 500

### Example python

import logging
from ad_api.api import CreativeAssets
from ad_api.base import AdvertisingApiException

def search_assets(data: dict or str):
    try:
        result = CreativeAssets(debug=True).search_assets(
            body=data
        )

        logging.info(result)

    except AdvertisingApiException as error:
        logging.info(error)

if __name__ == '__main__':

    search = \
        {
            "text": "Logo",
            "filterCriteria": {
                "valueFilters": [
                    {
                        "values": [
                            "B08XW4FDJV"
                        ],
                        "valueField": "ASIN"
                    }
                ]
            },
            "sortCriteria": {
                "field": "CREATED_TIME",
                "order": "ASC"
            }
        }

# If you send a empty query search = {} it will return all the assets in library
search_assets(search)

### Example search.json

Download json template

{
  "text": "string",
  "filterCriteria": {
    "valueFilters": [
      {
        "values": [
          "string"
        ],
        "valueField": "TAG"
      }
    ],
    "rangeFilters": [
      {
        "range": [
          {
            "start": "string",
            "end": "string"
          }
        ]
      }
    ]
  },
  "sortCriteria": {
    "field": "CREATED_TIME",
    "order": "ASC"
  },
  "pageCriteria": {
    "identifier": {
      "pageNumber": 0,
      "token": "string"
    },
    "size": 0
  }
}
get_asset(assetId: str, version: str) ApiResponse

Retrieves an asset along with the metadata

query assetId:string | Required. The assetId

query version:string | Optional. The versionId of the asset, if not included all versions will return.

### Example python

import logging
from ad_api.api import CreativeAssets
from ad_api.base import AdvertisingApiException


def get_asset(**kwargs):
    try:
        result = CreativeAssets(debug=True).get_asset(
            **kwargs
        )

        logging.info(result)

    except AdvertisingApiException as error:
        logging.info(error)

if __name__ == '__main__':

    amz_asset_id = "amzn1.assetlibrary.asset1.c2867a8671670fc7a5d0bf1efa295d599"
    amz_version = "version_v3"
    # get a specific version of the asset
    get_asset(assetId=amz_asset_id, version=amz_version)
    # get all versions of the asset
    get_asset(assetId=amz_asset_id)
upload_asset(body: dict, str, file) ApiResponse

body: | REQUIRED

{
fileName’: string The fileName of the asset. pattern: [w]+.jpg|png|mp4|mov|wmv|avi
}

### Example python

import logging
from ad_api.api import CreativeAssets
from ad_api.base import AdvertisingApiException


def upload_asset(data: dict or str):
    try:
        result = CreativeAssets(debug=True).upload_asset(
            body=data
        )

        url = result.payload.get("url")
        logging.info(url)

    except AdvertisingApiException as error:
        logging.info(error)

if __name__ == '__main__':

    file_name = "Sample-1000x1000.jpeg"

    asset = \
        {
            "fileName": file_name
        }

    upload_asset(asset)

Warning

After upload the assets it will return a url is the url location to which you will be uploading your asset

Note

This is not part of the Creative Assets api is just an example to upload the file using requests in python if your response.status_code is 200 everything is fine

from requests import request


def upload_file(_method, _url, _img):

    response = request(
        _method,
        _url,
        data=open(_img, 'rb')
    )

    logging.info(response.status_code)
    logging.info(response.headers)
    logging.info(response.content)
    logging.info(response.raw)


if __name__ == '__main__':

    file_name = "Sample-1200x1200.jpeg"
    url = "https://al-eu-726f4d26-7fdb.s3-accelerate.amazonaws.com/037764c3-6b70-4da9-b9af-8ef6ed136def.jpeg?x-amz-meta-filename=Sample-1200x1200.jpeg&X-Amz-Security-Token=token&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220421T035013Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=credential%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=a9cbeb0bd3d31e0c1a71c4ad27be23cd7725438581cc4e8a1f9f3f8d"
    method = "PUT"
    upload_file(method, url, file_name)
register_asset(body: dict, str, file) ApiResponse

Registers an uploaded asset with the creative assets library with optional contextual and tagging information. The API should be called once the asset is uploaded to the location provided by the /asset/upload API endpoint.

body: | REQUIRED {‘description’: ‘A caSearchRequestCommon}’

url | string | Required The url to upload the asset. The url expires in 15 minutes.
name | string | Required The name to be given to the asset being registered.
asinList | list | Optional Tagging assets with ASIN, promotes asset discoverability downstream. If ASIN is provided at the time of upload/during asset registration, it is applied as a tag on that asset. This allows for that asset to be searchable using that ASIN#. For e.g., An advertiser may want to search for assets tagged with ASIN BC10001, so they can create a store spotlight ad with product images for that ASIN.
assetType | string | The asset type you are registering [IMAGE]
assetSubTypeList | list | For assetType IMAGE acceptable assetSubTypes are LOGO, PRODUCT_IMAGE, AUTHOR_IMAGE, LIFESTYLE_IMAGE, OTHER_IMAGE.
versionInfo | string | The asset type you are registering [IMAGE]
linkedAssetId | string | The registering asset will be created as a new version of this linkedAssetId.
versionNotes | string | The version notes that client can associate to the asset.Versioning enables users to update an old asset, so that you can ensure the latest asset is being used. You can upload a new version of an existing asset along with version notes. Any tags/ASINs from previous version, will be retained on the new version too.
tags | list |
registrationContext | caRegistrationContext | This is used on registration of an asset, to associate DSP assets to a specific advertiser. This is required for assets being uploaded for use in DSP. | associatedPrograms | caAssociatedProgramcaAssociatedProgram |
metadata | string | Include key-value pairs related to the asset. For DSP use “dspAdvertiserId” = “ID”. Include program as AMAZON_DSP.
programName | string | Use this field to specify which program you are uploading an asset for. Currently, the accepted value here on registration is to associate an asset with a DSP advertiser. [ AMAZON_DSP ]
associatedSubEntityList | caAssociatedSubEntityList | This field is required for sellers, but not required for vendors. The brandEntityId is required for sellers uploading assets for use in Sponsored Brands. As a best practice, ensure to include brandEntityId when uploading assets for sellers.
caAssociatedSubEntity |
brandEntityId | string | The entity id of brand, which can be retrieved using GET /brands.
skipAssetSubTypesDetection | boolean | Select true if you want to set an asset to a specific assetSubType, if this is not included the system may reclassify your asset based on specifications.

### Example python

import logging
from ad_api.api import CreativeAssets
from ad_api.base import AdvertisingApiException


def register_asset(data: dict or str):
    try:
        result = CreativeAssets(debug=True).register_asset(
            body=data
        )

        logging.info(result)

    except AdvertisingApiException as error:
        logging.info(error)


if __name__ == '__main__':

    # the url was obtained with upload_asset method and was used to upload the file and finally register
    url = "https://al-eu-726f4d26-7fdb.s3-accelerate.amazonaws.com/037764c3-6b70-4da9-b9af-8ef6ed136def.jpeg?x-amz-meta-filename=Sample-1200x1200.jpeg&X-Amz-Security-Token=token&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20220421T035013Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Credential=credential%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=a9cbeb0bd3d31e0c1a71c4ad27be23cd7725438581cc4e8a1f9f3f8d"

    # register and assets already uploaded as a new asset
    register = \
        {
            "url": url,
            "name": "PRODUCT-IMAGE-NAME",
            "assetType": "IMAGE",
            "assetSubTypeList": [
                "PRODUCT_IMAGE"
            ],
            "associatedSubEntityList": [
                {
                    "brandEntityId": "ENTITY288756GCCQ6CF"
                }
            ],
            "skipAssetSubTypesDetection": True
        }


    # register and assets already uploaded as a new version of an existing assets

    register = \
        {
            "url": url,
            "name": "PRODUCT-IMAGE-NAME-2",
            "assetType": "IMAGE",
            "assetSubTypeList": [
                "PRODUCT_IMAGE"
            ],
            "versionInfo": {
                "linkedAssetId": "amzn1.assetlibrary.asset1.c2867a8671670fc7a5d0bf1efa295d599",
                "versionNotes": "version v2 of an existing asset"
            },
            "associatedSubEntityList": [
                {
                    "brandEntityId": "ENTITY1234567890123"
                }
            ],
            "skipAssetSubTypesDetection": True
        }


    register_asset(register)