Thanks for clarifying that you’re working with Gift Cards rather than discount codes, and for sharing your current liquid implementation.
For your headless migration, it’s important to note that the Storefront API currently doesn’t support fetching gift cards.
To handle this specific case in your headless setup, I recommend implementing URL redirects to ensure your gift card pages continue to work properly.
Documentation on that here: Redirect traffic to the Hydrogen channel
Since the gift card page is hosted on the checkout domain, the redirect theme includes a gift_card.liquid template specifically to address this current limitation.