--- title: codeDiscountNodeByCode - GraphQL Admin description: >- Retrieves a [code discount](https://help.shopify.com/manual/discounts/discount-types#discount-codes) by its discount code. The search is case-insensitive, enabling you to find discounts regardless of how customers enter the code. Returns a [`DiscountCodeNode`](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountCodeNode) that contains the underlying discount details, which could be a basic [amount off discount](https://help.shopify.com/manual/discounts/discount-types/percentage-fixed-amount), a ["Buy X Get Y" (BXGY) discount](https://help.shopify.com/manual/discounts/discount-types/buy-x-get-y), a [free shipping discount](https://help.shopify.com/manual/discounts/discount-types/free-shipping), or an [app-provided discount](https://help.shopify.com/manual/discounts/discount-types/discounts-with-apps). Learn more about working with [Shopify's discount model](https://shopify.dev/docs/apps/build/discounts). api_version: 2026-01 api_name: admin type: query api_type: graphql source_url: html: >- https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNodeByCode md: >- https://shopify.dev/docs/api/admin-graphql/latest/queries/codeDiscountNodeByCode.md --- # code​Discount​Node​By​Code query Requires Apps must have `read_discounts` access scope. Retrieves a [code discount](https://help.shopify.com/manual/discounts/discount-types#discount-codes) by its discount code. The search is case-insensitive, enabling you to find discounts regardless of how customers enter the code. Returns a [`DiscountCodeNode`](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountCodeNode) that contains the underlying discount details, which could be a basic [amount off discount](https://help.shopify.com/manual/discounts/discount-types/percentage-fixed-amount), a ["Buy X Get Y" (BXGY) discount](https://help.shopify.com/manual/discounts/discount-types/buy-x-get-y), a [free shipping discount](https://help.shopify.com/manual/discounts/discount-types/free-shipping), or an [app-provided discount](https://help.shopify.com/manual/discounts/discount-types/discounts-with-apps). Learn more about working with [Shopify's discount model](https://shopify.dev/docs/apps/build/discounts). ## Arguments * code *** ## Possible returns * DiscountCodeNode *** ## Examples * ### Search for a code discount by discount code #### Description Searching for a code discount by a valid discount code will return the code discount. #### Query ```graphql query codeDiscountNodeByCode($code: String!) { codeDiscountNodeByCode(code: $code) { codeDiscount { __typename ... on DiscountCodeBasic { codesCount { count } shortSummary } } id } } ``` #### Variables ```json { "code": "DISCOUNTAPPLICATIONSROCKS" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query codeDiscountNodeByCode($code: String!) { codeDiscountNodeByCode(code: $code) { codeDiscount { __typename ... on DiscountCodeBasic { codesCount { count } shortSummary } } id } }", "variables": { "code": "DISCOUNTAPPLICATIONSROCKS" } }' ``` #### 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 codeDiscountNodeByCode($code: String!) { codeDiscountNodeByCode(code: $code) { codeDiscount { __typename ... on DiscountCodeBasic { codesCount { count } shortSummary } } id } }`, { variables: { "code": "DISCOUNTAPPLICATIONSROCKS" }, }, ); 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 codeDiscountNodeByCode($code: String!) { codeDiscountNodeByCode(code: $code) { codeDiscount { __typename ... on DiscountCodeBasic { codesCount { count } shortSummary } } id } } QUERY variables = { "code": "DISCOUNTAPPLICATIONSROCKS" } 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 codeDiscountNodeByCode($code: String!) { codeDiscountNodeByCode(code: $code) { codeDiscount { __typename ... on DiscountCodeBasic { codesCount { count } shortSummary } } id } }`, "variables": { "code": "DISCOUNTAPPLICATIONSROCKS" }, }, }); ``` #### Response ```json { "codeDiscountNodeByCode": { "codeDiscount": { "__typename": "DiscountCodeBasic", "codesCount": { "count": 1 }, "shortSummary": "$10.00 off Element (151cm)" }, "id": "gid://shopify/DiscountCodeNode/573794601" } } ```