Main Image Relationship

Create a Main Image Relationship

POST https://api.moltin.com/v2/products/:productId/relationships/main-image

Create a Product relationship to a single File, which can be used as a main_image. You can only have one main image relationship.

Path Parameters

NameTypeDescription

productId

string

The ID of the product you wish to relate to the image.

Headers

NameTypeDescription

Authorization

string

The Bearer token used to access the API.

Request Body

NameTypeDescription

data[].type

string

Represents the type of the object (should be main_image).

data[].id

string

The ID of the image.

{
    "data": [
        {
            "type": "main_image",
            "id": "8df7738-febe-4987-bc0e-b857297b30e9"
        }
    ]
}
curl -X "POST" https://api.moltin.com/v2/products/:productId/relationships/main-image \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "type": "main_image",
        "id": "98df7738-febe-4987-bc0e-b857297b30e9"
      }
    }'

Update a Main Image Relationship

PUT https://api.moltin.com/v2/products/:productId/relationships/main-image

Update the main image relationship. This will replace any currently related image.

Path Parameters

NameTypeDescription

productId

string

The ID of the product you wish to relate to the image.

Headers

NameTypeDescription

Authorization

string

The Bearer token used to access the API.

Request Body

NameTypeDescription

data[].type

string

Represents the type of object (should be main_image)

data[].id

string

The ID of the image.

{
    "data": [
        {
            "type": "main_image",
            "id": "e9737dc6-876a-4eab-b3b7-af62a1999123"
        }
    ]
}
curl -X "PUT" https://api.moltin.com/v2/products/:productId/relationships/main-image \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "type": "main_image",
        "id": "e9737dc6-876a-4eab-b3b7-af62a1999123"
      }
    }'

Delete a Main Image Relationship

DELETE https://api.moltin.com/v2/products/:productId/relationships/main-image

Delete the main image relationship. This will remove the related main image.

Path Parameters

NameTypeDescription

productId

string

The ID of the product you wish to remove the relationship for.

Headers

NameTypeDescription

Authorization

string

The Bearer token used to access the API.

Request Body

NameTypeDescription

data[].type

string

Represents the type of object (should be main_image).

data[].id

string

The ID of the image.

curl -X "DELETE" https://api.moltin.com/v2/products/:productId/relationships/main-image \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
      "data": {
        "type": "main_image",
        "id": "e9737dc6-876a-4eab-b3b7-af62a1999123"
      }
    }'

Last updated