V1 and V2Products (V1)

Link an asset to a product

POST
/api/v1/products/{product_id}/assets

Link an existing asset to an existing media attribute of a product.

All parameters are mandatory:

  • id of the product.
  • id of the asset.
  • label of the attribute

Unknown parameters will be ignored from request data.

Note: This method does not allow the creation of new attributes, nor upload of new assets to your PIM.

ParameterDescriptionTypeMandatory
idasset idstringyes
attribute_labelmedia attribute labelstringyes

Assets can be linked to product thumbnail and product custom media attributes. Custom product attributes are located under “attributes” parameter.

Note: Assets linked to a single product are restricted to a limit of 300 assets per product.

Thumbnail and single media attribute linking

To link an existing asset to any of this kind of attribute, asset identifier and attribute_label are mandatory.
Caution: This action will replace existing asset in thumbnail or single media attribute if present.

Media gallery attribute linking

To link an existing asset to any of this kind of attribute, asset identifier and attribute_label are mandatory.
Attention: This action will add the asset to the media gallery attribute.

Example 1: link asset to thumbnail

POST /api/v1/products/6397116da02483ebd6dc76e0/assets

{   "id": "5c4ed8002f0985001e233275",   "attribute_label": "thumbnail"}

Example 2: link asset to custom attribute

POST /api/v1/products/6397116da02483ebd6dc76e0/assets

{   "id": "5c4ed8002f0985001e233275",   "attribute_label": "dummy_media_gallery"}

Authorization

bearerAuth
AuthorizationBearer <token>

Obtain a token via POST /auth/api/get-token (15 minute lifetime), then send it as Authorization: Bearer <token>.

In: header

Path Parameters

product_id*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

curl -X POST 'https://example.com/api/v1/products/string/assets' \  -H 'Content-Type: application/json' \  --data-raw '{  "id": "5c4ed8002f0985001e233275",  "attribute_label": "dummy_media_attribute"}'
{  "data": [    {      "id": "5c4ed8002f0985001e233275"    }  ]}