Skip to main content
POST
/
admin
/
products
/
{id}
/
images
/
{image_id}
/
variants
/
batch
JS SDK
import Switchyard from "@switchyard/js-sdk"

export const sdk = new Medusa({
  baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
  debug: import.meta.env.DEV,
  auth: {
    type: "session",
  },
})

sdk.admin.product.batchImageVariants("prod_123", "img_123", {
  add: ["variant_123", "variant_456"],
  remove: ["variant_789"]
})
.then(({ added, removed }) => {
  console.log(added, removed)
})
{
"added": [
"<string>"
],
"removed": [
"<string>"
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

The product's ID.

image_id
string
required

The product image's ID.

Body

application/json

Details of the associations between variants and a product image to manage.

add
string[]

The IDs of product variants to add the image to.

The ID of the variant to add.

remove
string[]

The IDs of product variants to remove the image from.

The ID of the variant to remove.

Response

OK

Result of managing the associations between variants and a product image.

added
string[]
required

The IDs of product variants added the image to.

The ID of the variant added.

removed
string[]
required

The IDs of product variants removed the image from.

The ID of the variant removed.