Discount codes guide
Add thousands of discount codes with Shopify CLI
Sign in to your store
Shopify CLI’s store commands use a stored sign-in. Run this once:
shopify store auth --store your-store.myshopify.com --scopes read_discounts,write_discountsRun one batch
Mutations are off by default. --allow-mutations turns them on for this command only.
shopify store execute --store your-store.myshopify.com --allow-mutations --json --version 2026-10 \
--query-file add-discount-codes.graphql \
--variables '{"discountId":"gid://shopify/DiscountCodeNode/123456789","codes":[{"code":"SPRING-7KQ4-M2XD"}]}'Run them all
The importer’s script writes the mutation to add-discount-codes.graphql, runs every batch one after another, and appends each JSON response to discount-code-results.jsonl. Paste that file back into the tool to check the jobs.
More guides
- How to import discount codes into Shopify from a CSV
- How to create thousands of unique discount codes in Shopify
- Add discount codes in bulk with the Shopify GraphiQL app
- Shopify discount code rules: length, capitals and limits
Sources: discountRedeemCodeBulkAdd, Shopify CLI store execute, Shopify Help Center: discount codes. Not affiliated with, endorsed by, or sponsored by Shopify Inc. Shopify is a trademark of Shopify Inc.