Products

Replace product media

Replaces the media of the Product and of its Variants at once.

PUT
/v1/products/{productId}/media

This is the only route that writes Product and Variant media. Create and update do not accept media: sending the key gives 400.

It is a PUT: the Product's list and the list of each Variant you send replace the stored ones. A Variant not in the body stays as it is.

  • product is the whole Product list. [] removes its media.
  • variants is required and carries only the Variants to write. A Variant that is not listed keeps its media. To clear a Variant's media, send it with media: [].
  • Each Variant appears once per call.
  • Archived Variants (and those of an archived Product) are accepted like any other.
  • position cannot repeat within the same role.
  • Up to 100 items per list and 100 Variants per call. A Product with more Variants is updated in several calls, each with the complete product.

Accepted types per role:

roleAccepts
imageJPEG, PNG or WebP
videoMP4
size_chartimage or PDF
documentPDF

video accepts MP4 video only: HEIC photos, M4A audio, and MOV do not pass as MP4 (the upload ends failed with unsupported_content).

All or nothing: if one item is refused, nothing is written. Nothing is published. But content that was published and is clean and uses this media becomes dirty when the new media differs from the published one (marketplace_product.updated, behavior: "product_changed", changes.paths product.media or variant.media). To carry the change to listings, use Propagate changes.

curl -X PUT "$API/v1/products/$PRODUCT_ID/media" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "product": [{ "assetId": "'$ASSET_ID'", "role": "image", "position": 0 }],
    "variants": [
      {
        "variantId": "'$VARIANT_ID'",
        "media": [{ "assetId": "'$ASSET_ID'", "role": "image", "position": 0 }]
      }
    ]
  }'

The other Variants of the Product stay as they are.

The response is the complete media after the swap, same as Get media. If the Product media changed, product.updated is emitted; for each Variant that changed, variant.updated.

Common errors

Asset errors carry details: { reason, assetId }:

  • 400 asset_not_found: the asset does not exist in this account.
  • 400 asset_seller_mismatch: the asset belongs to another seller. Copy it first with Copy media (POST /v1/sellers/{sellerId}/media-copies) and use the new id.
  • 400 asset_not_product_media: the asset is confidential. Only media assets can be cited.
  • 409 asset_not_ready: the asset is not ready yet. If the upload is pending, finish it or wait and retry. If it ended failed, it never becomes ready: upload a new file.
  • 400 asset_type_mismatch: the file type is not valid for the role (see the table).
  • 400 variant_not_in_product: a variantId is not a Variant of this Product.

Authorization

api_key
headerAuthorizationBearer <token>

API key (mk_...)

Path Parameters

productId*string
Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid

Request Body

application/json
  1. body

The complete media of a product, and the complete media of each listed variant. It replaces what is stored for them; variants left out are not touched.

product*array<>

Complete media list of the product; an empty list removes its media.

Itemsitems <= 100
variants*array<>

Media of the variants to write, at most 100 per request, archived ones included. A variant left out keeps its media; send media: [] to remove it. To write more than 100 variants, send several requests.

Itemsitems <= 100

Response Body

The complete media after replacement.

application/json
  1. response

The media of a product and of each of its variants.

productId*string

Product the media belongs to.

Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
product*array<>

Ordered product media.

variants*array<>

Every variant of the product, in the order GET /v1/products/{productId}/variants lists them.

curl -X PUT "https://example.com/v1/products/497f6eca-6276-4993-bfeb-53cbbbba6f08/media" \  -H "Content-Type: application/json" \  -d '{    "product": [      {        "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80",        "role": "image",        "position": 0      }    ],    "variants": [      {        "variantId": "47c9f819-fcf6-4478-b21a-678ecc594a11",        "media": [          {            "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80",            "role": "image",            "position": 0          }        ]      }    ]  }'
{  "productId": "a0f0ce59-5d17-49bf-8b45-d1dc057daab4",  "product": [    {      "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80",      "role": "image",      "position": 0    }  ],  "variants": [    {      "variantId": "47c9f819-fcf6-4478-b21a-678ecc594a11",      "media": [        {          "assetId": "4a7f2701-c5f7-477f-9658-5ce6be74ef80",          "role": "image",          "position": 0        }      ]    }  ]}