Is it possible to filter gift cards by code in Shopify admin api?

I am trying to use this graphql query to filter gift card by code

query getGiftCards{
  giftCards(first: 5, query: "code:TEST1234") {
    edges {
      node {
        id
        maskedCode
        balance{
          amount
        }
        enabled
      }
    }
  }
}

But this is not working. I know that gift card code is not exposed to anyone except the recipient. Just wanted to confirm if there is any other way to filter by code through the admin api or is it not possible?

1 Like

reading the documentation it states that the default query searches for codes, so perhaps the query will work if you don’t specify which field you are filtering for. Try something like this.

query getGiftCards{
  giftCards(first: 5, query: "TEST1234") {
    edges {
      node {
        id
        maskedCode
        balance{
          amount
        }
        enabled
      }
    }
  }
}
1 Like