Skip to content

Create Cart Rule

Creates a cart rule — the Create Cart Rule action on the admin Marketing → Promotions → Cart Rules screen. A cart rule discounts the cart at checkout, optionally gated behind a coupon code.

TIP

New here? Read the Cart Rules overview for what a cart rule does and how its fields behave.

Operation

OperationTypePurpose
createAdminMarketingCartRuleMutationCreate a cart rule

Details

  • Requires an admin Bearer token and the marketing.promotions.cart_rules.create permission.
  • When couponType is 1 and useAutoGeneration is 0, a unique couponCode is required — it becomes the rule's single primary coupon. Bulk codes are managed through the Cart Rule Coupons sub-resource.
  • The mutation returns the full rule payload, including the resolved conditions, channels, and customerGroups.

Input fields

FieldTypeRequiredNotes
nameStringYesRule name
descriptionStringNoFree-text description
channelsArrayYesNon-empty list of channel ids
customerGroupsArrayYesNon-empty list of customer-group ids
couponTypeIntNo0 no coupon (auto-applies) / 1 specific coupon
useAutoGenerationIntNo1 to auto-generate coupon codes
couponCodeStringNoRequired + unique when couponType is 1 and useAutoGeneration is 0
actionTypeStringYesby_percent, by_fixed, cart_fixed, buy_x_get_y
discountAmountFloatYesDiscount value; capped at 100 when actionType is by_percent
discountQuantityIntNoQuantity for buy_x_get_y
discountStepStringNoBuy-step for buy_x_get_y
applyToShippingIntNo1 applies the discount to shipping too
freeShippingIntNo1 grants free shipping
conditionTypeIntNo1 match all conditions / 0 match any
conditionsArrayNoCart / product condition filters
endOtherRulesIntNo1 stops lower-priority rules from also applying
usesAttributeConditionsIntNo1 when conditions use product attributes
usagePerCustomerIntNoPer-customer usage limit (0 = unlimited)
usesPerCouponIntNoPer-coupon usage limit (0 = unlimited)
sortOrderIntNoPriority — lower runs first
statusIntNo0 inactive / 1 active
startsFromStringNoStart date (ISO 8601) or null
endsTillStringNoEnd date (ISO 8601) or null; must be >= startsFrom

Released under the MIT License.