discountCodeRedeemCodeBulkDelete
Requires Apps must have access scope.
Asynchronously delete discount codes in bulk that customers can use to redeem a discount.
Arguments
- Anchor to discountIddiscount•
Id ID!required The ID of the
object that the codes will be removed from. For example,
. You can use the
query to retrieve the ID.
- •
The IDs of the
objects to delete. For example,
. You can use the
query to retrieve the ID.
- Anchor to savedSearchIdsaved•
Search Id The ID of a saved search.
- Anchor to searchsearch•
A filter made up of terms, connectives, modifiers, and comparators that you can use to search for code discounts. You can apply one or more filters to a query. Learn more about Shopify API search syntax.
For a list of accepted values for the
search
field, refer to thequery
argument on thequery.
Anchor to DiscountCodeRedeemCodeBulkDeletePayload returnsDiscountCodeRedeemCodeBulkDeletePayload returns
- •
The asynchronous job that deletes the discount codes.
- Anchor to userErrorsuser•
Errors [DiscountUser non-nullError!]! The list of errors that occurred from executing the mutation.
- Asynchronously delete discount redeem codes in bulk using a search filter
- Deletes a discount code
- Using more than one targeting argument returns an error
- discountCodeRedeemCodeBulkDelete reference
Examples
mutation discountCodeRedeemCodeBulkDelete($discountId: ID!, $search: String) {
discountCodeRedeemCodeBulkDelete(discountId: $discountId, search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation discountCodeRedeemCodeBulkDelete($discountId: ID!, $search: String) { discountCodeRedeemCodeBulkDelete(discountId: $discountId, search: $search) { job { id } userErrors { code field message } } }",
"variables": {
"discountId": "gid://shopify/DiscountCodeNode/2429471",
"search": "times_used:0"
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation discountCodeRedeemCodeBulkDelete($discountId: ID!, $search: String) {
discountCodeRedeemCodeBulkDelete(discountId: $discountId, search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}`,
{
variables: {
"discountId": "gid://shopify/DiscountCodeNode/2429471",
"search": "times_used:0"
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation discountCodeRedeemCodeBulkDelete($discountId: ID!, $search: String) {
discountCodeRedeemCodeBulkDelete(discountId: $discountId, search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}`,
"variables": {
"discountId": "gid://shopify/DiscountCodeNode/2429471",
"search": "times_used:0"
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation discountCodeRedeemCodeBulkDelete($discountId: ID!, $search: String) {
discountCodeRedeemCodeBulkDelete(discountId: $discountId, search: $search) {
job {
id
}
userErrors {
code
field
message
}
}
}
QUERY
variables = {
"discountId": "gid://shopify/DiscountCodeNode/2429471",
"search": "times_used:0"
}
response = client.query(query: query, variables: variables)