Generate Custom Gift Card Code

Shopify Partner
15 0 2

I am currently attempting to modify gift cards after they are purchased. My end goal would be to, before fulfillment and the gift card is sent to the customer, manually set the gift card code from my own generated numbers.


So far using a webhook I am able to at least see orders, but the gift card is already created before I am able to catch it. Once the gift card is created, it's no longer possible to change the gift card code.


I am looking for a point in the right direction as to how to accomplish this. I am open to using any of the technology that Shopify has available. Not sure if this needs to be done using the shopify functions, or if this is something that can be accomplished using a webhook.


Thank you

Replies 2 (2)

Shopify Staff
2731 297 768

Hi TravisImagine,


Shopify doesn't currently have an API endpoint to update gift cards due to the sensitive nature of gift cards and data associated with them. The currently available API endpoints related to gift cards are for retrieving and searching gift cards, not for creating or updating them.


If you want to use custom gift card numbers, you might need to create a custom solution outside of Shopify. For example, you could generate a code and store it along with the gift card's unique ID (which is accessible via the API) in your app's database. When the gift card is used, you would then check the custom code against your database, get the real gift card code, and use that to process the payment on Shopify. But in this approach customers would only be seeing the Shopify generated code. 


Another option might be to modify the post purchase process. You could continue to use the order webhook, but instead of trying to modify the Shopify gift card, generate your own custom code and send it to the customer as an additional gift. 


Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog

Shopify Partner
15 0 2

Hello Liam,


Thanks for the response. As for your first point, gift cards do have an update endpoint. However, you cannot update the ID, which is maybe what you were trying to say. However there is also a gift card create endpoint.


I was hoping to be able to use the gift card create endpoint before fulfillment, by deleting the gift card from the order line, then replacing it with the new one. What I'm trying to avoid though, is sending two separate emails.


I already have a custom solution outside of Shopify that generates the numbers. It saves them as well, and I do intend to attach the Shopify gift card ID to the number. This way, when I import orders, I can match up the Shopify gift card used, to the gift card in the other system.


You mention modifying the post purchase process to generate my own code and send it as an additional gift. I don't think that would work for my solution, as I am trying to avoid sending two separate emails.


Is there a way in post purchase processing, to delete a gift card or other line item from an order?