---
title: "codeDiscountNodes"
description: "Get the store's discount code activities."
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/queries/code-discount-nodes'
  md: 'https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/queries/code-discount-nodes.md'
---
# codeDiscountNodes

Get the store's discount code activities.

- **Required Scopes:** `read_discounts`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Query

## Required Permissions

* `read_discounts`

An access token is required to call this API. Refer to [Authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md) for more information about how to obtain the token.

## Arguments

* `after`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Returns elements following the specified cursor. The `first` argument must also be specified when using this argument.

* `before`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Returns elements preceding the specified cursor. The `last` argument must also be specified when using this argument.

* `first`

  [Int](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/int.md)

  Returns the first n elements in the list. 

* `last`

  [Int](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/int.md)

  Returns the last n elements in the list. 

* `reverse`

  [Boolean](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/boolean.md)

  Whether to reverse the order of the list. 
  
  ● true: reverse
  
  ● false: do not reverse
  
  Default value: false

* `query`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Specify one or more query filters. Supported filters and their valid values are as follows:  
  * `discount_type`: The discount benefit type. Valid values are:
    - `bogo`: Buy X, get Y free.
    - `fix_amount`: Amount discount.
    - `percentage`: Percentage discount.
    - `free_shipping`: Free shipping.
  * `status`: The activity status. Valid values are:
    - `active`: The activity is live and ongoing.
    - `expired`: The activity has expired.
    - `scheduled`: The activity has not started yet.
  * `times_used`: The usage count or the usage count range of the discount.  
    For example, `times_used:>0` means filtering discounts that have been used at least once.
  * `starts_at`: The date and time when the activity starts, or a time scope during which the activity starts.  
    For example, `starts_at:>='2023-01-10T00:00:00Z'` means filtering activities that started after `2023-01-10T00:00:00Z`.
  * `title`: The name of the activity, where any keyword passed in must be enclosed in `''`.  
    Filtering by title applies fuzzy matching.
  * `code`: The discount code, where any keyword passed in must be enclosed in `''`.  
    Filtering by discount code applies exact matching.
  * `sales_channel`: The sales channel. Valid values are:
    - `web`: Online sales channel.
    - `pos`: POS channel.
    - `all`: All sales channels.
  * `source_key`: Specifies the creation source of the discount.

* `sortKey`

  [CodeDiscountSortKeys](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/enums/code-discount-sort-keys.md)

  The key for sorting the filtered discount code activities. For example, `STARTS_AT` means sorting by the start time, and `TIMES_USED` means sorting by the usage count.

## Returns

* `edges`

  [[DiscountCodeNodeEdge!]](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-code-node-edge.md)

  A list of edges.

* `nodes`

  [[DiscountCodeNode]](https://developer.shopline.com/docs/admin-graph-ql-api/discounts-and-marketing/objects/discount-code-node.md)

  Information to aid in pagination.

* `pageInfo`

  [PageInfo!](https://developer.shopline.com/docs/admin-graph-ql-api/common-objects/objects/page-info.md)

  A list of the nodes contained in DiscountCodeNodeEdge.

## Examples

### Get discount code activities by title

Use the title as a filter to query discount code activities.

**Request:**

```json
query MyQuery {
  codeDiscountNodes(
    first: 10
       query: "title:'demo'"
    sortKey: CREATED_AT
    reverse: true
  ) {
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
    edges {
      cursor
      node {
        codeDiscount {
          ... on DiscountCodeBasic {
            summary
              shareableUrls {
            targetType
            title
            url
          }
            asyncUsageCount
            codeCount
            codes
            appliesTimesPerCustomer
            createdAt
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            customerGets {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountAmount {
                  appliesOnEachItem
                  amount {
                    amount
                    currencyCode
                  }
                }
                ... on DiscountPercentage {
                  __typename
                  percentage
                }
                ... on DiscountOnQuantity {
                  __typename
                  effect {
                    ... on DiscountAmount {
                      appliesOnEachItem
                      amount {
                        amount
                        currencyCode
                      }
                    }
                    ... on DiscountPercentage {
                      __typename
                      percentage
                    }
                  }
                  quantity {
                    quantity
                  }
                }
              }
            }
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            discountClass
            endsAt
            minimumRequirement {
              ... on DiscountMinimumQuantity {
                __typename
                greaterThanOrEqualToQuantity
              }
              ... on DiscountMinimumSubtotal {
                __typename
                greaterThanOrEqualToSubtotal {
                  amount
                  currencyCode
                }
              }
            }
            shareableUrls {
              targetType
              title
              url
            }
            shortSummary
            startsAt
            status
            title
            updatedAt
            totalSales {
              amount
              currencyCode
            }
            usageLimit
          }
          ... on DiscountCodeBxgy {
            summary
            asyncUsageCount
            appliesTimesPerCustomer
            codeCount
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            createdAt
            customerBuys {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountQuantity {
                  __typename
                  quantity
                }
                ... on DiscountPurchaseAmount {
                  amount
                }
              }
            }
            customerGets {
              items {
                ... on AllDiscountItems {
                  __typename
                  allItems
                }
                ... on DiscountCollections {
                  __typename
                  collections
                }
                ... on DiscountProducts {
                  __typename
                  productVariants
                  products
                }
              }
              value {
                ... on DiscountAmount {
                  appliesOnEachItem
                  amount {
                    amount
                    currencyCode
                  }
                }
                ... on DiscountPercentage {
                  __typename
                  percentage
                }
                ... on DiscountOnQuantity {
                  __typename
                  effect {
                    ... on DiscountAmount {
                      appliesOnEachItem
                      amount {
                        amount
                        currencyCode
                      }
                    }
                    ... on DiscountPercentage {
                      __typename
                      percentage
                    }
                  }
                  quantity {
                    quantity
                  }
                }
              }
            }
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            discountClass
            endsAt
            shareableUrls {
              targetType
              title
              url
            }
            startsAt
            status
            title
            totalSales {
              amount
              currencyCode
            }
            usageLimit
            usesPerOrderLimit
          }
          ... on DiscountCodeFreeShipping {
            summary
            asyncUsageCount
            appliesTimesPerCustomer
            codeCount
            combinesWith {
              orderDiscounts
              productDiscounts
              shippingDiscounts
            }
            createdAt
            customerSelection {
              ... on DiscountCustomerAll {
                allCustomers
              }
              ... on DiscountCustomerSegments {
                __typename
                segments
              }
              ... on DiscountCustomers {
                __typename
                customers
              }
            }
            destinationSelection {
              ... on DiscountCountries {
                includeRestOfWorld
                countries
              }
              ... on DiscountCountryAll {
                allCountries
              }
            }
            discountClass
            endsAt
            maximumShippingPrice {
              amount
              currencyCode
            }
            minimumRequirement {
              ... on DiscountMinimumQuantity {
                __typename
                greaterThanOrEqualToQuantity
              }
              ... on DiscountMinimumSubtotal {
                __typename
                greaterThanOrEqualToSubtotal {
                  amount
                  currencyCode
                }
              }
            }
            shareableUrls {
              targetType
              title
              url
            }
            shortSummary
            startsAt
            status
            title
            updatedAt
            usageLimit
            totalSales {
              amount
              currencyCode
            }
          }
        }
        id
      }
    }
    nodes {
      codeDiscount {
        ... on DiscountCodeBasic {
          summary
            shareableUrls {
            targetType
            title
            url
          }
          asyncUsageCount
          codeCount
          createdAt
          endsAt
          shortSummary
          startsAt
          status
          title
          codes
          updatedAt
          usageLimit
          appliesTimesPerCustomer
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          customerGets {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountAmount {
                appliesOnEachItem
                amount {
                  amount
                  currencyCode
                }
              }
              ... on DiscountPercentage {
                __typename
                percentage
              }
              ... on DiscountOnQuantity {
                __typename
                effect {
                  ... on DiscountAmount {
                    appliesOnEachItem
                    amount {
                      amount
                      currencyCode
                    }
                  }
                  ... on DiscountPercentage {
                    __typename
                    percentage
                  }
                }
                quantity {
                  quantity
                }
              }
            }
          }
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          discountClass
          minimumRequirement {
            ... on DiscountMinimumQuantity {
              __typename
              greaterThanOrEqualToQuantity
            }
            ... on DiscountMinimumSubtotal {
              __typename
              greaterThanOrEqualToSubtotal {
                amount
                currencyCode
              }
            }
          }
      
          totalSales {
            amount
            currencyCode
          }
        }
        ... on DiscountCodeBxgy {
          summary
          asyncUsageCount
          title
          appliesTimesPerCustomer
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          codeCount
          createdAt
          customerBuys {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountQuantity {
                __typename
                quantity
              }
              ... on DiscountPurchaseAmount {
                amount
              }
            }
          }
          customerGets {
            items {
              ... on AllDiscountItems {
                __typename
                allItems
              }
              ... on DiscountCollections {
                __typename
                collections
              }
              ... on DiscountProducts {
                __typename
                productVariants
                products
              }
            }
            value {
              ... on DiscountAmount {
                appliesOnEachItem
                amount {
                  amount
                  currencyCode
                }
              }
              ... on DiscountPercentage {
                __typename
                percentage
              }
              ... on DiscountOnQuantity {
                __typename
                effect {
                  ... on DiscountAmount {
                    appliesOnEachItem
                    amount {
                      amount
                      currencyCode
                    }
                  }
                  ... on DiscountPercentage {
                    __typename
                    percentage
                  }
                }
                quantity {
                  quantity
                }
              }
            }
          }
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          discountClass
          endsAt
          shareableUrls {
            targetType
            title
            url
          }
          startsAt
          status
          totalSales {
            amount
            currencyCode
          }
          usageLimit
          usesPerOrderLimit
        }
        ... on DiscountCodeFreeShipping {
          summary
          asyncUsageCount
          appliesTimesPerCustomer
          codeCount
          combinesWith {
            orderDiscounts
            productDiscounts
            shippingDiscounts
          }
          createdAt
          customerSelection {
            ... on DiscountCustomerAll {
              allCustomers
            }
            ... on DiscountCustomerSegments {
              __typename
              segments
            }
            ... on DiscountCustomers {
              __typename
              customers
            }
          }
          destinationSelection {
            ... on DiscountCountries {
              includeRestOfWorld
              countries
            }
            ... on DiscountCountryAll {
              allCountries
            }
          }
          discountClass
          endsAt
          maximumShippingPrice {
            amount
            currencyCode
          }
          minimumRequirement {
            ... on DiscountMinimumQuantity {
              __typename
              greaterThanOrEqualToQuantity
            }
            ... on DiscountMinimumSubtotal {
              __typename
              greaterThanOrEqualToSubtotal {
                amount
                currencyCode
              }
            }
          }
          shareableUrls {
            targetType
            title
            url
          }
          shortSummary
          startsAt
          status
          title
          totalSales {
            amount
            currencyCode
          }
          updatedAt
          usageLimit
        }
      }
      id
    }
  }
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "codeDiscountNodes": {
        "pageInfo": {
          "startCursor": "2AAF90F13C58A5EF353DD555E8D6CCD6",
          "endCursor": "C61FAE0199C84A33DB551A7831B8E034",
          "hasNextPage": false,
          "hasPreviousPage": false
        },
        "edges": [
          {
            "cursor": "-",
            "node": {
              "codeDiscount": {
                "combinesWith": {
                  "orderDiscounts": false,
                  "productDiscounts": false,
                  "shippingDiscounts": false
                },
                "shareableUrls": [
                  {
                    "targetType": "HOME",
                    "title": "demo",
                    "url": "https://ella01pre.myshoplinestg.com/activity/SL201SAS07614802632470692879"
                  }
                ],
                "status": "ACTIVE",
                "endsAt": "2026-07-18T08:41:54.000Z",
                "totalSales": {
                  "amount": "0",
                  "currencyCode": "SGD"
                },
                "updatedAt": "2026-07-16T12:41:55.000Z",
                "customerSelection": {
                  "__typename": "DiscountCustomers",
                  "customers": [
                    "4208821948"
                  ]
                },
                "discountClass": "PRODUCT",
                "minimumRequirement": {
                  "__typename": "DiscountMinimumSubtotal",
                  "greaterThanOrEqualToSubtotal": {
                    "amount": "100.56",
                    "currencyCode": "SGD"
                  }
                },
                "shortSummary": "22.32 off 6 products",
                "startsAt": "2025-12-30T08:41:54.000Z",
                "asyncUsageCount": 0,
                "codeCount": 1,
                "createdAt": "2026-07-16T12:41:54.000Z",
                "customerGets": {
                  "items": {
                    "__typename": "DiscountProducts",
                    "productVariants": [],
                    "products": [
                      "16064393365790313753160195",
                      "16064393365833431198690195",
                      "16064393365879904087440195",
                      "16064393365916813963040195",
                      "16064393365975701991600195",
                      "16064393366023181513580195"
                    ]
                  },
                  "value": {
                    "amount": {
                      "currencyCode": "SGD",
                      "amount": "22.32"
                    },
                    "appliesOnEachItem": true
                  }
                },
                "summary": "22.32 off 6 products • Minimum purchase of 100.56 • Applies to each eligible item per order",
                "title": "demo",
                "usageLimit": -1,
                "appliesTimesPerCustomer": -1,
                "codes": [
                  "995639"
                ]
              },
              "id": "gid://shopline/DiscountCodeNode/SL201SAS07614802632470692879"
            }
          }
        ],
        "nodes": [
          {
            "codeDiscount": {
              "appliesTimesPerCustomer": -1,
              "minimumRequirement": {
                "__typename": "DiscountMinimumSubtotal",
                "greaterThanOrEqualToSubtotal": {
                  "amount": "100.56",
                  "currencyCode": "SGD"
                }
              },
              "shortSummary": "22.32 off 6 products",
              "totalSales": {
                "amount": "0",
                "currencyCode": "SGD"
              },
              "customerGets": {
                "items": {
                  "__typename": "DiscountProducts",
                  "productVariants": [],
                  "products": [
                    "16064393365790313753160195",
                    "16064393365833431198690195",
                    "16064393365879904087440195",
                    "16064393365916813963040195",
                    "16064393365975701991600195",
                    "16064393366023181513580195"
                  ]
                },
                "value": {
                  "amount": {
                    "amount": "22.32",
                    "currencyCode": "SGD"
                  },
                  "appliesOnEachItem": true
                }
              },
              "discountClass": "PRODUCT",
              "summary": "22.32 off 6 products • Minimum purchase of 100.56 • Applies to each eligible item per order",
              "title": "demo",
              "asyncUsageCount": 0,
              "codeCount": 1,
              "endsAt": "2026-07-18T08:41:54.000Z",
              "startsAt": "2025-12-30T08:41:54.000Z",
              "status": "ACTIVE",
              "updatedAt": "2026-07-16T12:41:55.000Z",
              "codes": [
                "995639"
              ],
              "combinesWith": {
                "orderDiscounts": false,
                "productDiscounts": false,
                "shippingDiscounts": false
              },
              "createdAt": "2026-07-16T12:41:54.000Z",
              "customerSelection": {
                "__typename": "DiscountCustomers",
                "customers": [
                  "4208821948"
                ]
              },
              "shareableUrls": [
                {
                  "targetType": "HOME",
                  "title": "demo",
                  "url": "https://ella01pre.myshoplinestg.com/activity/SL201SAS07614802632470692879"
                }
              ],
              "usageLimit": -1
            },
            "id": "gid://shopline/DiscountCodeNode/SL201SAS07614802632470692879"
          }
        ]
      }
    },
    "extensions": {
      "cost": {
        "actualQueryCost": 131,
        "requestedQueryCost": 131,
        "throttleStatus": {
          "currentlyAvailable": 49869,
          "maximumAvailable": 50000,
          "restoreRate": 50000
        }
      }
    }
  }
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes).

