Discount codes guide

Add thousands of discount codes with Shopify CLI

Download my script

Sign in to your store

Shopify CLI’s store commands use a stored sign-in. Run this once:

Terminal
shopify store auth --store your-store.myshopify.com --scopes read_discounts,write_discounts

Run one batch

Mutations are off by default. --allow-mutations turns them on for this command only.

Terminal
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

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.