POST
/
admin
/
products
/
{id}
/
variants
/
inventory-items
/
batch
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.

Response

200
application/json

OK

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