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.priceList.batchPrices("plist_123", {
create: [{
variant_id: "variant_123",
currency_code: "usd",
amount: 10,
rules: {
region_id: "reg_123"
}
}],
update: [{
id: "price_123",
variant_id: "variant_123",
amount: 20,
}],
delete: ["price_123"]
})
.then(({ created, updated, deleted }) => {
console.log(created, updated, deleted)
})
{
"created": [
{
"id": "<string>",
"title": "<string>",
"currency_code": "usd",
"amount": 123,
"raw_amount": {},
"min_quantity": 123,
"max_quantity": 123,
"price_set_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"updated": [
{
"id": "<string>",
"title": "<string>",
"currency_code": "usd",
"amount": 123,
"raw_amount": {},
"min_quantity": 123,
"max_quantity": 123,
"price_set_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"deleted": {
"ids": [
"<string>"
],
"object": "price",
"deleted": true
}
}
Manage the prices of a price list to create, update, or delete them.
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.priceList.batchPrices("plist_123", {
create: [{
variant_id: "variant_123",
currency_code: "usd",
amount: 10,
rules: {
region_id: "reg_123"
}
}],
update: [{
id: "price_123",
variant_id: "variant_123",
amount: 20,
}],
delete: ["price_123"]
})
.then(({ created, updated, deleted }) => {
console.log(created, updated, deleted)
})
{
"created": [
{
"id": "<string>",
"title": "<string>",
"currency_code": "usd",
"amount": 123,
"raw_amount": {},
"min_quantity": 123,
"max_quantity": 123,
"price_set_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"updated": [
{
"id": "<string>",
"title": "<string>",
"currency_code": "usd",
"amount": 123,
"raw_amount": {},
"min_quantity": 123,
"max_quantity": 123,
"price_set_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
],
"deleted": {
"ids": [
"<string>"
],
"object": "price",
"deleted": true
}
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
The price list's ID.
The prices to create, update, or delete.
OK
The details of the created, updated, and deleted prices in a price list.