Hi, reporting a bug.
When creating a discount code, a userError is returned is customerSelection is not set in the input variables.
However the graphQL documentation states that customerSelection is a deprecated field.
Either the documentation for discountCodeBasicCreate is wrong, or the handler is wrong and it should not be insisting that we provide a deprecated field.
The documentation for managing discount codes is a little lacking in general, it is very difficult to figure out how to provide the different kinds of inputs for things like DiscountCollections. Some more examples would be very helpful.
See screenshot below for this specific error:
1 Like
Hi @dartacus,
I’ve tried replicating this on my own test store with API version 2025-10 and I have not been able to so far.
With the discountCodeBasicCreate mutation, I’m passing specific customers to add to the discount via the new context field that replaces the customerSelection field as mentioned in the documentation, and I’m fully able to create the discounts without any errors occurring. Here’s an example of the inputs I’m using for this mutation.
{
"basicCodeDiscount": {
"title": "$20 off for VIP customers",
"code": "VIP20OFF",
"startsAt": "2025-07-24T16:16:22-04:00",
"endsAt": null,
"context": {
"customers": {
"add": [
"gid://shopify/Customer/12345678910",
]
}
},
"customerGets": {
"value": {
"discountAmount": {
"amount": "20.00",
"appliesOnEachItem": false
}
},
"items": {
"all": true
}
},
"appliesOncePerCustomer": true
}
}
If I don’t pass both the context and customerSelection field, I get the Context can't be blank error message.
If I don’t pass the context field, but pass the deprecated customerSelection field instead, it does still work to create the discount, but it does get identified as a deprecated call and will be added to the deprecated call lists in the API Health section of your Dev Dashboard.
If you are still experiencing this error, please double check the API version you are using with your calls, as this context field was added in version 2025-10 specifically, as mentioned in the following changelog post.
If you’re still experiencing this error with version 2025-10 we can absolutely help look into this further, if you can provide the following details from an API call that returned the error.
- The full plain text HTTP Request, including URL, Body, and Headers (no access tokens)
- The full plain text HTTP Response, including Body and Headers
Thanks Kellan, I’m OOO tomorrow but I’ll have a look Wednesday.
G
Hi @dartacus,
I just wanted to follow up and see if you were able to replicate this behaviour or if it’s resolved for you now? If so we can go ahead and mark this thread as solved, otherwise I’m happy to help continue looking into this with you if you can provide the x-request-id from the HTTP Response Headers of an API call returning this error.
Hi Kellan,
You can mark this as resolved, I didn’t have time to check but I think this was down to old API version as you state.
Many thanks for your continued attention,
Gareth
1 Like