--- title: productVariantByIdentifier - GraphQL Admin description: Return a product variant by an identifier. api_version: 2025-04 api_name: admin type: query api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/2025-04/queries/productvariantbyidentifier md: https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/input-objects/ProductVariantIdentifierInput) required The identifier of the product variant. *** ## Possible returns * Product​Variant [Product​Variant](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/scalars/Boolean) non-null Whether the product variant is available for sale. * barcode [String](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/String) The value of the barcode associated with the product. * compare​At​Price [Money](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/DateTime) non-null The date and time when the variant was created. * default​Cursor [String!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/objects/DeliveryProfile) The [delivery profile](https://shopify.dev/api/admin-graphql/latest/objects/DeliveryProfile) for the variant. * display​Name [String!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/connections/EventConnection) non-null The paginated list of events associated with the host subject. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Event​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/scalars/ID) non-null A globally-unique ID. * inventory​Item [Inventory​Item!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/scalars/Int) The total sellable quantity of the variant. * legacy​Resource​Id [Unsigned​Int64!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/connections/MediaConnection) non-null The media associated with the product variant. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafield [Metafield](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/scalars/String) required The key for the metafield. *** * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * position [Int!](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/scalars/Money) non-null The price of the product variant in the default shop currency. * product [Product!](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/Product) non-null The product that this variant belongs to. * product​Variant​Components [Product​Variant​Component​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-04/connections/ProductVariantComponentConnection) non-null A list of the product variant components. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * requires​Components [Boolean!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Boolean) non-null Whether a product variant requires components. The default value is `false`. If `true`, then the product variant can only be purchased as a parent bundle with components and it will be omitted from channels that don't support bundles. * selected​Options [\[Selected​Option!\]!](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/SelectedOption) non-null List of product options applied to the variant. * sellable​Online​Quantity [Int!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Int) non-null The total sellable quantity of the variant for online channels. This doesn't represent the total available inventory or capture [limitations based on customer location](https://help.shopify.com/manual/markets/inventory_and_fulfillment). * selling​Plan​Groups [Selling​Plan​Group​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-04/connections/SellingPlanGroupConnection) non-null A list of all selling plan groups defined in the current shop associated with the product variant. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * selling​Plan​Groups​Count [Count](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/Count) Count of selling plan groups associated with the product variant. * sku [String](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/String) A case-sensitive identifier for the product variant in the shop. Required in order to connect to a fulfillment service. * taxable [Boolean!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Boolean) non-null Whether a tax is charged when the product variant is sold. * title [String!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/String) non-null The title of the product variant. * translations [\[Translation!\]!](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/Translation) non-null The published translations associated with the resource. * locale [String!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/String) required ### Arguments Filters translations locale. * market​Id [ID](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/ID) Filters translations by market ID. Use this argument to retrieve content specific to a market. *** * unit​Price​Measurement [Unit​Price​Measurement](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/UnitPriceMeasurement) The unit price measurement for the variant. * updated​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/DateTime) non-null The date and time (ISO 8601 format) when the product variant was last modified. * image [Image](https://shopify.dev/docs/api/admin-graphql/2025-04/objects/Image) Deprecated * max​Width [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Int) Deprecated ### Arguments * max​Height [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Int) Deprecated * crop [Crop​Region](https://shopify.dev/docs/api/admin-graphql/2025-04/enums/CropRegion) Deprecated * scale [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/Int) DeprecatedDefault:1 *** * metafield​Definitions [Metafield​Definition​Connection!](https://shopify.dev/docs/api/admin-graphql/2025-04/connections/MetafieldDefinitionConnection) non-nullDeprecated * namespace [String](https://shopify.dev/docs/api/admin-graphql/2025-04/scalars/String) ### Arguments Filter metafield definitions by namespace. * pinned​Status [Metafield​Definition​Pinned​Status](https://shopify.dev/docs/api/admin-graphql/2025-04/enums/MetafieldDefinitionPinnedStatus) Default:ANY Filter by the definition's pinned status. * first [Int](https://shopify.dev/docs/api/admin-graphql/2025-04/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/2025-04/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/2025-04/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/2025-04/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/2025-04/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Metafield​Definition​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/2025-04/enums/MetafieldDefinitionSortKeys) 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/2025-04/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 * created\_at time * id id * key string * namespace string * owner\_type string * type string * updated\_at time - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the date and time when the metafield definition was created. - Example: * `created_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/2025-04/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" } } ```