POST
/
admin
/
products
/
{id}
/
variants
/
inventory-items
/
batch
JS SDK
import Medusa from "@medusajs/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.batchVariantInventoryItems(
  "prod_123",
  {
    create: [
      {
        inventory_item_id: "iitem_123",
        variant_id: "variant_123",
        required_quantity: 10
      }
    ],
    update: [
      {
        inventory_item_id: "iitem_1234",
        variant_id: "variant_1234",
        required_quantity: 20
      }
    ],
    delete: [
      {
        inventory_item_id: "iitem_321",
        variant_id: "variant_321"
      }
    ]
  }
)
.then(({ created, updated, deleted }) => {
  console.log(created, updated, deleted)
})
{
"created": {
"Product": {
"variant_id": "<string>"
},
"Inventory": {
"inventory_item_id": "<string>"
}
},
"updated": {
"Product": {
"variant_id": "<string>"
},
"Inventory": {
"inventory_item_id": "<string>"
}
},
"deleted": {
"Product": {
"variant_id": "<string>"
},
"Inventory": {
"inventory_item_id": "<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.

Body

application/json

The product variant inventories to manage.

create
object[]

The The associations to create between product variants and inventory items.

update
object[]

The product variants to update their association with inventory items.

delete
object[]

The product variants to delete their association with inventory items.

Response

OK

The created, updated, and deleted associations between variants and inventory items.

created
required

The details of an association between a product variant and an inventory item.

updated
required

The details of an association between a product variant and an inventory item.

deleted
required

The details of an association between a product variant and an inventory item.