Skip to content

Create Cart Rule

Creates a cart rule — the Create Rule action on the admin Marketing → Promotions → Cart Rules screen. A cart rule discounts the shopper's cart at checkout and can optionally be gated by a coupon code.

TIP

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

Endpoint

EndpointMethod
/api/admin/marketing/cart-rulesPOST

Details

  • Requires an admin Bearer token and the marketing.promotions.cart_rules.create permission.
  • When coupon_type is 1 and use_auto_generation is 0, coupon_code is required and must be unique. With use_auto_generation set to 1, codes are generated for you.
  • Returns the full rule payload, including the resolved conditions, channels, and customerGroups.

Request body

FieldTypeRequiredNotes
namestringyesRule name
descriptionstringnoFree-text description
channelsint[]yesNon-empty list of channel ids
customer_groupsint[]yesNon-empty list of customer-group ids
coupon_typeintno0 auto-apply when conditions match / 1 specific code
use_auto_generationintno1 to auto-generate coupon codes
coupon_codestringconditionalRequired + unique when coupon_type is 1 and use_auto_generation is 0
action_typestringyesby_percent, by_fixed, cart_fixed, buy_x_get_y
discount_amountnumberyesDiscount value; capped at 100 when action_type is by_percent
discount_quantityintnoQuantity for buy_x_get_y
discount_stepstringnoStep for buy_x_get_y
apply_to_shippingintno1 applies the discount to shipping
free_shippingintno1 grants free shipping
condition_typeintno1 match all conditions / 0 match any
conditionsarraynoCart / product filters
end_other_rulesintno1 stops lower-priority rules from also applying
uses_attribute_conditionsintno1 when conditions use product attributes
usage_per_customerintnoPer-customer usage cap (0 = unlimited)
uses_per_couponintnoPer-coupon usage cap (0 = unlimited)
sort_orderintnoPriority — lower runs first
statusintno0 inactive / 1 active
starts_fromstringnoStart date (YYYY-MM-DD) or null
ends_tillstringnoEnd date (YYYY-MM-DD) or null; must be >= starts_from

Released under the MIT License.