--- title: productVariantByIdentifier - GraphQL Admin description: Return a product variant by an identifier. api_version: unstable api_name: admin source_url: html: https://shopify.dev/docs/api/admin-graphql/unstable/queries/productvariantbyidentifier md: https://shopify.dev/docs/api/admin-graphql/unstable/queries/productvariantbyidentifier.md --- # product​Variant​By​Identifier query Requires `read_products` access scope. Return a product variant by an identifier. ## Arguments * identifier [Product​Variant​Identifier​Input!](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/ProductVariantIdentifierInput) required The identifier of the product variant. *** ## Possible returns * Product​Variant [Product​Variant](https://shopify.dev/docs/api/admin-graphql/unstable/objects/ProductVariant) The `ProductVariant` object represents a version of a [product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) that comes in more than one [option](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption), such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. Use the `ProductVariant` object to manage the full lifecycle and configuration of a product's variants. Common use cases for using the `ProductVariant` object include: * Tracking inventory for each variant * Setting unique prices for each variant * Assigning barcodes and SKUs to connect variants to fulfillment services * Attaching variant-specific images and media * Setting delivery and tax requirements * Supporting product bundles, subscriptions, and selling plans A `ProductVariant` is associated with a parent [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) object. `ProductVariant` serves as the central link between a product's merchandising configuration, inventory, pricing, fulfillment, and sales channels within the GraphQL Admin API schema. Each variant can reference other GraphQL types such as: * [`InventoryItem`](https://shopify.dev/docs/api/admin-graphql/latest/objects/InventoryItem): Used for inventory tracking * [`Image`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Image): Used for variant-specific images * [`SellingPlanGroup`](https://shopify.dev/docs/api/admin-graphql/latest/objects/SellingPlanGroup): Used for subscriptions and selling plans Learn more about [Shopify's product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components). * available​For​Sale [Boolean!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) non-null Whether the product variant is available for sale. * barcode [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The value of the barcode associated with the product. * compare​At​Price [Money](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Money) The compare-at price of the variant in the default shop currency. * contextual​Pricing [Product​Variant​Contextual​Pricing!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/ProductVariantContextualPricing) non-null The pricing that applies for a customer in a given context. As of API version 2025-04, only active markets are considered in the price resolution. * context [Contextual​Pricing​Context!](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/ContextualPricingContext) required ### Arguments The context used to generate contextual pricing for the variant. *** * created​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/DateTime) non-null The date and time when the variant was created. * default​Cursor [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * delivery​Profile [Delivery​Profile](https://shopify.dev/docs/api/admin-graphql/unstable/objects/DeliveryProfile) The [delivery profile](https://shopify.dev/api/admin-graphql/latest/objects/DeliveryProfile) for the variant. * delivery​Promise​Participants [\[Delivery​Promise​Participant!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/DeliveryPromiseParticipant) non-null The delivery promise participants for the product variant. * branded​Promise​Handle [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) required ### Arguments The branded promise handle to filter by. *** * display​Name [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) non-null Display name of the variant, based on product's title + variant's title. * events [Event​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/EventConnection) non-null The paginated list of events associated with the host subject. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Event​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/unstable/enums/EventSortKeys) Default:ID Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). * query [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * action string * comments boolean * created\_at time * id id * subject\_type string - The action that occured. - Example: * `action:create` Whether or not to include [comment-events](https://shopify.dev/api/admin-graphql/latest/objects/CommentEvent) in your search, passing `false` will exclude comment-events, any other value will include comment-events. - Example: * `false` * `true` Filter by the date and time when the event happened. - Example: * `created_at:>2020-10-21` * `created_at:=1234` * `id:<=1234` The resource type affected by this event. See [EventSubjectType](https://shopify.dev/api/admin-graphql/latest/enums/EventSubjectType) for possible values. Example: * `PRODUCT_VARIANT` * `PRODUCT` * `COLLECTION` *** * id [ID!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/ID) non-null A globally-unique ID. * inventory​Item [Inventory​Item!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/InventoryItem) non-null The inventory item, which is used to query for inventory information. * inventory​Policy [Product​Variant​Inventory​Policy!](https://shopify.dev/docs/api/admin-graphql/unstable/enums/ProductVariantInventoryPolicy) non-null Whether customers are allowed to place an order for the product variant when it's out of stock. * inventory​Quantity [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The total sellable quantity of the variant. * legacy​Resource​Id [Unsigned​Int64!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/UnsignedInt64) non-null The ID of the corresponding resource in the REST Admin API. * media [Media​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MediaConnection) non-null The media associated with the product variant. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafield [Metafield](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments The container the metafield belongs to. If omitted, the app-reserved namespace will be used. * key [String!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) required The key for the metafield. *** * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/MetafieldConnection) non-null A list of [custom fields](https://shopify.dev/docs/apps/build/custom-data) that a merchant associates with a Shopify resource. * namespace [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) ### Arguments The metafield namespace to filter by. If omitted, the app-reserved namespace will be used. * keys [\[String!\]](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) List of keys of metafields in the format `namespace.key`, will be returned in the same format. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafields​By​Identifiers [\[Metafield\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Metafield) non-null The metafields associated with the resource matching the supplied list of namespaces and keys. * identifiers [\[Has​Metafields​Identifier!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/HasMetafieldsIdentifier) required ### Arguments The list of metafields to retrieve by namespace and key. *** * position [Int!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) non-null The order of the product variant in the list of product variants. The first position in the list is 1. * price [Money!](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Money) non-null The price of the product variant in the default shop currency. * product [Product!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/Product) non-null The product that this variant belongs to. * product​Parents [Product​Connection!](https://shopify.dev/docs/api/admin-graphql/unstable/connections/ProductConnection) non-null A list of products that have product variants that contain this variant as a product component. * first [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/Boolean) Default:false Reverse the order of the underlying list. * query [String](https://shopify.dev/docs/api/admin-graphql/unstable/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * default string * barcode string * bundles boolean * category\_id string * collection\_id id * combined\_listing\_role string * created\_at time * delivery\_profile\_id id * error\_feedback string - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the product variant [`barcode`](https://shopify.dev/api/admin-graphql/latest/objects/ProductVariant#field-barcode) field. - Example: * `barcode:ABC-abc-1234` Filter by a [product bundle](https://shopify.dev/docs/apps/build/product-merchandising/bundles). A product bundle is a set of two or more related products, which are commonly offered at a discount. - Example: * `bundles:true` Filter by the product [category ID](https://shopify.dev/api/admin-graphql/latest/objects/Product#field-category) (`product.category.id`). A product category is the category of a product from [Shopify's Standard Product Taxonomy](https://shopify.github.io/product-taxonomy/releases/unstable/?categoryId=sg-4-17-2-17). - Example: * `category_id:sg-4-17-2-17` Filter by the collection [`id`](https://shopify.dev/api/admin-graphql/latest/objects/Collection#field-id) field. - Example: * `collection_id:108179161409` Filter by the role of the product in a [combined listing](https://shopify.dev/apps/build/product-merchandising/combined-listings). - Valid values: * `parent` * `child` * `no_role` Example: * `combined_listing_role:parent` Filter by the date and time when the product was created. - Example: * `created_at:>'2020-10-21T23:39:20Z'` * `created_at:=1234` * `id:<=1234` Filter by inventory count. - Example: * `inventory_total:0` * `inventory_total:>150` * `inventory_total:>=200` Filter by products that have a reduced price. For more information, refer to the [`CollectionRule`](https://shopify.dev/api/admin-graphql/latest/objects/CollectionRule) object. - Example: * `is_price_reduced:true` Filters resources by metafield value. Format: `metafields.{namespace}.{key}:{value}`. Learn more about [querying by metafield value](https://shopify.dev/apps/build/custom-data/metafields/query-by-metafield-value). - Example: * `metafields.custom.on_sale:true` * `metafields.product.material:"gid://shopify/Metaobject/43458085"` Filter by products that are out of stock in at least one location. - Example: * `out_of_stock_somewhere:true` Filter by the product variant [`price`](https://shopify.dev/api/admin-graphql/latest/objects/Productvariant#field-price) field. - Example: * `price:100.57` Filter by the app [`id`](https://shopify.dev/api/admin-graphql/latest/objects/App#field-id) field. - Example: * `product_configuration_owner:10001` Filter by the publication status of the resource on a channel, such as the online store. The value is a composite of the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) and one of the valid values. - Valid values: * `approved` * `rejected` * `needs_action` * `awaiting_review` * `published` * `demoted` * `scheduled` * `provisionally_published` Example: * `product_publication_status:189769876-approved` Filter by a comma-separated list of [product types](https://help.shopify.com/manual/products/details/product-type). - Example: * `product_type:snowboard` Filter by a comma-separated list of publication IDs that are associated with the product. - Example: * `publication_ids:184111530305,184111694145` Filter by the publishable status of the resource on a channel, such as the online store. The value is a composite of either the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) or [channel `name`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Channel#field-name) and one of the valid values. - Valid values: * `online_store_channel` * `published` * `unpublished` * `visible` * `unavailable` * `hidden` * `intended` * `visible` Example: * `publishable_status:published` * `publishable_status:189769876-visible` * `publishable_status:pos-hidden` Filter by the date and time when the product was published to the online store and other sales channels. - Example: * `published_at:>2020-10-21T23:39:20Z` * `published_at:'2020-10-21T23:39:20Z'` * `updated_at:2020-10-21T23:39:20Z` * `created_at:=1234` * `id:<=1234` Filter by the metafield definition [`key`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-key) field. - Example: * `key:some-key` Filter by the metafield definition [`namespace`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-namespace) field. - Example: * `namespace:some-namespace` Filter by the metafield definition [`ownerType`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-ownertype) field. - Example: * `owner_type:PRODUCT` Filter by the metafield definition [`type`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-type) field. - Example: * `type:single_line_text_field` Filter by the date and time when the metafield definition was last updated. Example: * `updated_at:>2020-10-21T23:39:20Z` * `updated_at: { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } }`, { variables: { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } } QUERY variables = { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } }`, "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } }, }, }); ``` #### Response ```json { "variant": { "id": "gid://shopify/ProductVariant/30322695", "title": "151cm" } } ``` ## Find a variant by custom id [Open in GraphiQL](http://localhost:3457/graphiql?query=query\(%24identifier%3A%20ProductVariantIdentifierInput!\)%20%7B%0A%20%20variant%3A%20productVariantByIdentifier\(identifier%3A%20%24identifier\)%20%7B%0A%20%20%20%20id%0A%20%20%20%20title%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22identifier%22%3A%20%7B%0A%20%20%20%20%22customId%22%3A%20%7B%0A%20%20%20%20%20%20%22namespace%22%3A%20%22custom%22%2C%0A%20%20%20%20%20%20%22key%22%3A%20%22id%22%2C%0A%20%20%20%20%20%20%22value%22%3A%20%221001%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) ##### GQL ```graphql query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } }", "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } } }' ``` ##### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } }`, { variables: { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } }`, "variables": { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } }, }, }); ``` ##### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query($identifier: ProductVariantIdentifierInput!) { variant: productVariantByIdentifier(identifier: $identifier) { id title } } QUERY variables = { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "identifier": { "customId": { "namespace": "custom", "key": "id", "value": "1001" } } } ``` ## Response JSON ```json { "variant": { "id": "gid://shopify/ProductVariant/30322695", "title": "151cm" } } ```