---
title: "Create a new cart rule"
method: POST
path: "/marketing/cart-rules"
tags: ["Admin Marketing: Promotions"]
---

# Create a new cart rule

`POST /marketing/cart-rules`

## Request

- Base URL: `http://localhost:8000/api/admin`
- URL: `http://localhost:8000/api/admin/marketing/cart-rules`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/bagisto/apis/bagisto-admin-api/docs/marketing/cart-rules/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new cart rule

## Request body

- object
  - `name` string, required
  - `description` string
  - `channels` integer[], required: Assigned channel ids (request stays id-based; the response returns objects).
  - `customer_groups` integer[], required: Assigned customer-group ids (request stays id-based; the response returns objects).
  - `coupon_type` 0 | 1, required: 0 = no coupon (auto-applied), 1 = specific coupon.
  - `use_auto_generation` 0 | 1: When coupon_type=1: 1 = auto-generate codes, 0 = use the supplied coupon_code.
  - `coupon_code` string: Required when coupon_type=1 and use_auto_generation=0; must be unique.
  - `uses_per_coupon` integer: Total redemptions allowed per coupon (0 = unlimited).
  - `usage_per_customer` integer: Redemptions allowed per customer (0 = unlimited).
  - `condition_type` 1 | 2: 1 = all conditions true, 2 = any condition true.
  - `conditions` object[]: Condition rows: { attribute, operator, value, attribute_type }.
  - `action_type` 'by_percent' | 'by_fixed' | 'cart_fixed' | 'buy_x_get_y', required
  - `discount_amount` number, required: 0-100 when action_type=by_percent.
  - `discount_quantity` integer: Max quantity discounted (buy_x_get_y).
  - `discount_step` integer: Buy-X step (buy_x_get_y).
  - `apply_to_shipping` 0 | 1: Apply the discount to shipping too.
  - `free_shipping` 0 | 1
  - `end_other_rules` 0 | 1: Stop processing further rules when this one matches.
  - `sort_order` integer: Priority (lower runs first).
  - `starts_from` string, date-time
  - `ends_till` string, date-time
  - `status` 0 | 1

## Response `201`

Cart rule created.

## Other responses

- `400`: Invalid input
- `422`: Validation failure.

---

[API](https://skmtc.dev/bagisto/apis/bagisto-admin-api.md) - [All operations](https://skmtc.dev/bagisto/apis/bagisto-admin-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bagisto/apis/bagisto-admin-api/revisions/3198f11be70f?raw)
