discountCodeBulkDelete will delete all type discount on your store

I’m currently looking for a GraphQL API that can delete a specific discount code from my store. Unfortunately, I mistakenly used the discountCodeBulkDelete API, which I initially assumed would only remove the selected discount code. However, it actually deletes entire discounts based on the associated code.

After running the API, within about 5 seconds, all discounts on my store were deleted — including both code-based and automatic discounts.

I contacted customer support, but they informed me that Shopify is unable to restore deleted discounts…

mutation discountCodeBulkDelete($search: String) {
discountCodeBulkDelete(search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
} {
“search”: “query:staff44443”
} this is my GraphQL query and Input variables

Hey @Kenn,

I was able to reproduce the behavior you experienced with discountCodeBulkDelete(search: "query:staff44443") and confirmed that it does delete all discounts on the store. The issue appears to occur because "query" isn’t a valid search field for discount operations, and seems to then be ignoring it. I’m currently working with our team to address exactly why this is happening.

For a workaround, the safest approach is to use discountCodeDelete with specific discount IDs instead. First, find your target discount using discountNodes(query: "title:*staff44443*") to get the ID, then delete it individually with discountCodeDelete(id: "your-discount-id").

I tested this method and it works, deleting only the specific discount without affecting others. You can also test using valid search fields like title:*staff44443* with the bulk delete mutation if you need to remove multiple matching discounts at once.

I would also recommend setting up a development store for testing beforehand so there aren’t any unexpected deletions in a live environment.

I’ll follow up here once I know more.

Hey @Kenn, I want to follow up and let you know that we have created an internal issue to look in to this. I will update here once there is a resolution. Thanks again for reporting that here.