--- displayed_sidebar: jsClientSidebar slug: /references/js-client/AdminVariantsResource --- import ParameterTypes from "@site/src/components/ParameterTypes" # AdminVariantsResource This class is used to send requests to [Admin Product Variant API Routes](https://docs.medusajs.com/api/admin#product-variants). All its method are available in the JS Client under the `medusa.admin.variants` property. All methods in this class require [user authentication](AdminAuthResource.mdx#createsession). Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product. Product variants can be managed through [AdminProductsResource](AdminProductsResource.mdx). Related Guide: [How to manage product variants](https://docs.medusajs.com/modules/products/admin/manage-products#manage-product-variants). ## Methods ### getInventory Retrieve the available inventory of a product variant. #### Example ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants.getInventory(variantId).then(({ variant }) => { console.log(variant.inventory, variant.sales_channel_availability) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns ___ ### list Retrieve a list of product variants. The product variant can be filtered by fields such as `id` or `title` passed in the `query` parameter. The product variant can also be paginated. #### Example To list product variants: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants.list().then(({ variants, limit, offset, count }) => { console.log(variants.length) }) ``` To specify relations that should be retrieved within the product variants: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants .list({ expand: "options", }) .then(({ variants, limit, offset, count }) => { console.log(variants.length) }) ``` By default, only the first `100` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants .list({ expand: "options", limit, offset, }) .then(({ variants, limit, offset, count }) => { console.log(variants.length) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "mid_code", "type": "`null` \\| `string`", "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "options", "type": "[ProductOptionValue](../internal/classes/internal.internal.ProductOptionValue.mdx)[]", "description": "The details of the product options that this product variant defines values for.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "origin_country", "type": "`null` \\| `string`", "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "prices", "type": "[MoneyAmount](../internal/classes/internal.internal.MoneyAmount.mdx)[]", "description": "The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product", "type": "[Product](../internal/classes/internal.Product.mdx)", "description": "The details of the product that the product variant belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product_id", "type": "`string`", "description": "The ID of the product that the product variant belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "purchasable", "type": "`boolean`", "description": "Only used with the inventory modules. A boolean value indicating whether the Product Variant is purchasable. A variant is purchasable if: - inventory is not managed - it has no inventory items - it is in stock - it is backorderable.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "sku", "type": "`null` \\| `string`", "description": "The unique stock keeping unit used to identify the Product Variant. This will usually be a unique identifer for the item that is to be shipped, and can be referenced across multiple systems.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "title", "type": "`string`", "description": "A title that can be displayed for easy identification of the Product Variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "upc", "type": "`null` \\| `string`", "description": "A UPC barcode number that can be used to identify the Product Variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "variant_rank", "type": "`null` \\| `number`", "description": "The ranking of this variant", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "weight", "type": "`null` \\| `number`", "description": "The weight of the Product Variant. May be used in shipping rate calculations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "width", "type": "`null` \\| `number`", "description": "The width of the Product Variant. May be used in shipping rate calculations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price", "type": "`number` \\| `null`", "description": "The lowest price among the retrieved prices.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price_includes_tax", "type": "`boolean` \\| `null`", "description": "Whether the `calculated_price` field includes taxes.", "optional": true, "defaultValue": "", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "calculated_price_type", "type": "`string` \\| `null`", "description": "Either `default` if the `calculated_price` is the original price, or the type of the price list applied, if any.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price", "type": "`number` \\| `null`", "description": "The original price of the variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price_includes_tax", "type": "`boolean` \\| `null`", "description": "Whether the `original_price` field includes taxes.", "optional": true, "defaultValue": "", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "prices", "type": "[MoneyAmount](../internal/classes/internal.internal.MoneyAmount.mdx)[]", "description": "The list of prices.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price_incl_tax", "type": "`number` \\| `null`", "description": "The price after applying the tax amount on the calculated price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_tax", "type": "`number` \\| `null`", "description": "The tax amount applied to the calculated price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price_incl_tax", "type": "`number` \\| `null`", "description": "The price after applying the tax amount on the original price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_tax", "type": "`number` \\| `null`", "description": "The tax amount applied to the original price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rates", "type": "[TaxServiceRate](../internal/types/internal.TaxServiceRate.mdx)[] \\| `null`", "description": "The list of tax rates.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} /> ___ ### retrieve Retrieve a product variant's details. #### Example A simple example that retrieves a product variant by its ID: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants.retrieve(variantId).then(({ variant }) => { console.log(variant.id) }) ``` To specify relations that should be retrieved: ```ts import Medusa from "@medusajs/medusa-js" const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 }) // must be previously logged in or use api token medusa.admin.variants .retrieve(variantId, { expand: "options", }) .then(({ variant }) => { console.log(variant.id) }) ``` #### Parameters `", "description": "Custom headers to attach to the request.", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `", "description": "An optional key-value map with additional details", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "mid_code", "type": "`null` \\| `string`", "description": "The Manufacturers Identification code that identifies the manufacturer of the Product Variant. May be used by Fulfillment Providers to pass customs information to shipping carriers.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "options", "type": "[ProductOptionValue](../internal/classes/internal.internal.ProductOptionValue.mdx)[]", "description": "The details of the product options that this product variant defines values for.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "origin_country", "type": "`null` \\| `string`", "description": "The country in which the Product Variant was produced. May be used by Fulfillment Providers to pass customs information to shipping carriers.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "prices", "type": "[MoneyAmount](../internal/classes/internal.internal.MoneyAmount.mdx)[]", "description": "The details of the prices of the Product Variant, each represented as a Money Amount. Each Money Amount represents a price in a given currency or a specific Region.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product", "type": "[Product](../internal/classes/internal.Product.mdx)", "description": "The details of the product that the product variant belongs to.", "optional": false, "defaultValue": "", "expandable": true, "children": [] }, { "name": "product_id", "type": "`string`", "description": "The ID of the product that the product variant belongs to.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "purchasable", "type": "`boolean`", "description": "Only used with the inventory modules. A boolean value indicating whether the Product Variant is purchasable. A variant is purchasable if: - inventory is not managed - it has no inventory items - it is in stock - it is backorderable.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "sku", "type": "`null` \\| `string`", "description": "The unique stock keeping unit used to identify the Product Variant. This will usually be a unique identifer for the item that is to be shipped, and can be referenced across multiple systems.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "title", "type": "`string`", "description": "A title that can be displayed for easy identification of the Product Variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "upc", "type": "`null` \\| `string`", "description": "A UPC barcode number that can be used to identify the Product Variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "updated_at", "type": "`Date`", "description": "The date with timezone at which the resource was updated.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "variant_rank", "type": "`null` \\| `number`", "description": "The ranking of this variant", "optional": false, "defaultValue": "0", "expandable": false, "children": [] }, { "name": "weight", "type": "`null` \\| `number`", "description": "The weight of the Product Variant. May be used in shipping rate calculations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "width", "type": "`null` \\| `number`", "description": "The width of the Product Variant. May be used in shipping rate calculations.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price", "type": "`number` \\| `null`", "description": "The lowest price among the retrieved prices.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price_includes_tax", "type": "`boolean` \\| `null`", "description": "Whether the `calculated_price` field includes taxes.", "optional": true, "defaultValue": "", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "calculated_price_type", "type": "`string` \\| `null`", "description": "Either `default` if the `calculated_price` is the original price, or the type of the price list applied, if any.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price", "type": "`number` \\| `null`", "description": "The original price of the variant.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price_includes_tax", "type": "`boolean` \\| `null`", "description": "Whether the `original_price` field includes taxes.", "optional": true, "defaultValue": "", "expandable": false, "featureFlag": "tax_inclusive_pricing", "children": [] }, { "name": "prices", "type": "[MoneyAmount](../internal/classes/internal.internal.MoneyAmount.mdx)[]", "description": "The list of prices.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_price_incl_tax", "type": "`number` \\| `null`", "description": "The price after applying the tax amount on the calculated price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "calculated_tax", "type": "`number` \\| `null`", "description": "The tax amount applied to the calculated price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_price_incl_tax", "type": "`number` \\| `null`", "description": "The price after applying the tax amount on the original price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "original_tax", "type": "`number` \\| `null`", "description": "The tax amount applied to the original price.", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "tax_rates", "type": "[TaxServiceRate](../internal/types/internal.TaxServiceRate.mdx)[] \\| `null`", "description": "The list of tax rates.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ] } ] } ] } ]} />