Issue: Creating a discount code for a specific customer using Shopify’s GraphQL API. The original mutation had formatting problems that prevented it from working correctly.
Solution provided:
Use the discountCodeBasicCreate mutation with proper structure
Key parameters include: discount title, code, start/end dates, customer selection, discount value (percentage), and items scope
For customer-specific discounts: use customerSelection with customers: { add: ["gid://shopify/Customer/CUSTOMER_ID"] }
Outcome: The corrected mutation format resolved the issue. The key was replacing the customer ID with the proper GID format (gid://shopify/Customer/[ID]).
Summarized with AI on November 7.
AI used: claude-sonnet-4-5-20250929.