--- title: discountAutomaticDelete - GraphQL Admin description: |- Deletes an existing automatic discount from the store, permanently removing it from all future order calculations. This mutation provides a clean way to remove promotional campaigns that are no longer needed. For example, when a seasonal promotion ends or a flash sale concludes, merchants can use this mutation to ensure the discount no longer applies to new orders while preserving historical order data. Use `DiscountAutomaticDelete` to: - Remove expired promotional campaigns - Clean up test discounts during development - Delete automatic discounts that conflict with new promotions - Maintain a clean discount configuration The mutation returns the ID of the deleted discount for confirmation and any validation errors if the deletion cannot be completed. Once deleted, the automatic discount will no longer appear in discount lists or apply to new customer orders. api_version: 2025-10 api_name: admin type: mutation api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete md: https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete.md --- # discount​Automatic​Delete mutation Requires Apps must have `write_discounts` access scope. Deletes an existing automatic discount from the store, permanently removing it from all future order calculations. This mutation provides a clean way to remove promotional campaigns that are no longer needed. For example, when a seasonal promotion ends or a flash sale concludes, merchants can use this mutation to ensure the discount no longer applies to new orders while preserving historical order data. Use `DiscountAutomaticDelete` to: * Remove expired promotional campaigns * Clean up test discounts during development * Delete automatic discounts that conflict with new promotions * Maintain a clean discount configuration The mutation returns the ID of the deleted discount for confirmation and any validation errors if the deletion cannot be completed. Once deleted, the automatic discount will no longer appear in discount lists or apply to new customer orders. ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) required The ID of the automatic discount to delete. *** ## Discount​Automatic​Delete​Payload returns * deleted​Automatic​Discount​Id [ID](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) The ID of the automatic discount that was deleted. * user​Errors [\[Discount​User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/latest/objects/DiscountUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Delete an automatic discount #### Description Deleting an automatic discount returns the ID of the deleted automatic discount #### Query ```graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } } ``` #### Variables ```json { "id": "gid://shopify/DiscountAutomaticNode/198286294" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }", "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }`, { variables: { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } } QUERY variables = { "id": "gid://shopify/DiscountAutomaticNode/198286294" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }`, "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, }); ``` #### Response ```json { "discountAutomaticDelete": { "deletedAutomaticDiscountId": "gid://shopify/DiscountAutomaticNode/198286294", "userErrors": [] } } ``` * ### Remove an existing PriceRule #### Query ```graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message } } } ``` #### Variables ```json { "id": "gid://shopify/DiscountAutomaticNode/198286294" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message } } }", "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message } } }`, { variables: { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message } } } QUERY variables = { "id": "gid://shopify/DiscountAutomaticNode/198286294" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field message } } }`, "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, }); ``` #### Response ```json { "discountAutomaticDelete": { "deletedAutomaticDiscountId": "gid://shopify/DiscountAutomaticNode/198286294", "userErrors": [] } } ``` * ### discountAutomaticDelete reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20discountAutomaticDelete\(%24id%3A%20ID!\)%20%7B%0A%20%20discountAutomaticDelete\(id%3A%20%24id\)%20%7B%0A%20%20%20%20deletedAutomaticDiscountId%0A%20%20%20%20userErrors%20%7B%0A%20%20%20%20%20%20field%0A%20%20%20%20%20%20code%0A%20%20%20%20%20%20message%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22id%22%3A%20%22gid%3A%2F%2Fshopify%2FDiscountAutomaticNode%2F198286294%22%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }`, { variables: { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }", "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }`, { variables: { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } }`, "variables": { "id": "gid://shopify/DiscountAutomaticNode/198286294" }, }, }); ``` ##### Ruby ``` 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 discountAutomaticDelete($id: ID!) { discountAutomaticDelete(id: $id) { deletedAutomaticDiscountId userErrors { field code message } } } QUERY variables = { "id": "gid://shopify/DiscountAutomaticNode/198286294" } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "id": "gid://shopify/DiscountAutomaticNode/198286294" } ``` ## Response JSON ```json { "discountAutomaticDelete": { "deletedAutomaticDiscountId": "gid://shopify/DiscountAutomaticNode/198286294", "userErrors": [] } } ```