Skip to content

Create Cart Rule Coupon

Adds a single coupon code to a cart rule — the Add Coupon action on the admin Marketing → Promotions → Cart Rules → Coupons screen.

TIP

New here? Read the Cart Rule Coupons overview for what a coupon does and how its fields behave.

Operation

OperationTypePurpose
createAdminMarketingCartRuleCouponMutationAdd one coupon code to a cart rule

Details

  • Requires an admin Bearer token and the marketing.promotions.cart_rules.create permission.
  • code must be unique across all cart-rule coupons.
  • Omitted usageLimit / usagePerCustomer / expiredAt inherit the parent rule's values.
  • The created coupon is always a secondary code: isPrimary is false and type is 1. The rule's primary code is managed on the cart rule itself.
  • To create many codes at once, use the generate mutation instead.

Input fields

FieldTypeRequiredNotes
cartRuleIdIntYesParent cart-rule id
codeStringYesCoupon code — must be unique
usageLimitIntNoTotal redemptions allowed; inherits the rule when omitted
usagePerCustomerIntNoRedemptions per customer; inherits the rule when omitted
expiredAtStringNoExpiry date (YYYY-MM-DD); inherits the rule when omitted

Released under the MIT License.