shopify discount automatic api for specfic products

Topic summary

A developer is trying to create automatic discounts for specific products via Shopify’s API, rather than applying discounts to all items.

Initial Question:

  • Found API documentation for creating automatic discounts but only for all products
  • Needs to target specific products instead

Suggested Solution:

  • Use the discountAutomaticBasicCreate mutation (the correct API)
  • Pass product IDs using this structure:
    items: {
      products: {
        productsToAdd: [product_ids]
      }
    }
    

Current Status:

  • Implementation returns a “bad request” error
  • Issue remains unresolved
  • The developer shared a screenshot of the error but hasn’t received further troubleshooting guidance
Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

How can we create automatic discounts for specific products using the API? In Shopify, I found an option for automatic discounts applied to all items, but I’m looking to apply it to specific products.

I found just for all item link: Shopify API Documentation on Automatic Discount Creation.

Hello @Anil918
Hope you are doing well
You are using correct API. Please checkout this screenshot.

You have to pass the data like this.

items: {  
         products: {
          productsToAdd: [product_ids]
         }
       }

its return bad request