> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# Category Promotion Code Samples

## Apply a \$ or % discount to each item in one or more categories

#### Request

**`Example request`**

```json title="Example request" showLineNumbers={false}
{
  "name": "20 dollars off all garden material",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "action": {
        "cart_items": {
          "discount": {
            "fixed_amount": "20"
          },
          "strategy": "LEAST_EXPENSIVE",
          "as_total": false,
          "include_items_considered_by_condition": false,
          "items": {
            "categories": [
              24
            ]
          }
        }
      },
      "apply_once": true,
      "stop": false
    }
  ],
  "notifications": [
    {
      "type": "UPSELL",
      "content": "",
      "locations": [
        "CART_PAGE"
      ]
    },
    {
      "type": "ELIGIBLE",
      "content": "",
      "locations": [
        "CART_PAGE"
      ]
    },
    {
      "type": "APPLIED",
      "content": "",
      "locations": [
        "CART_PAGE"
      ]
    }
  ],
  "stop": false,
  "start_date": "2019-01-29T00:00:00+00:00",
  "status": "ENABLED"
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 10,
    "name": "20 dollars off all garden material",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "fixed_amount": "20"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
              "categories": [
                24
              ]
            }
          }
        },
        "apply_once": true,
        "stop": false
      }
    ],
    "notifications": [
      {
        "type": "UPSELL",
        "content": "",
        "locations": [
          "CART_PAGE"
        ]
      },
      {
        "type": "ELIGIBLE",
        "content": "",
        "locations": [
          "CART_PAGE"
        ]
      },
      {
        "type": "APPLIED",
        "content": "",
        "locations": [
          "CART_PAGE"
        ]
      }
    ],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2019-01-29T00:00:00+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Apply a \$ or % discount to each item in one or more categories, exclude items on sale

#### Request

**`Example request`**

```json title="Example request" showLineNumbers={false}
{
  "name": "20 dollars off all garden material, exclude items on sale",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "action": {
        "cart_items": {
          "discount": {
            "fixed_amount": "20"
          },
          "strategy": "LEAST_EXPENSIVE",
          "as_total": false,
          "include_items_considered_by_condition": false,
          "exclude_items_on_sale": true,
          "items": {
            "categories": [
              19
            ]
          }
        }
      },
      "apply_once": true,
      "stop": false
    }
  ]
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 11,
    "name": "20 dollars off all garden material, exclude items on sale",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "fixed_amount": "5"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": true,
            "items": {
              "categories": [
                36
              ]
            }
          }
        },
        "apply_once": true,
        "stop": false
      }
    ],
    "notifications": [],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2022-07-18T18:43:58+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Buy X units in (category A) and get Y additional units in the same category free (must be of equal or lesser value)

#### Request

**`Example request`**

```json title="Example request"
{
  "name": "Buy X units in (Category A) and get Y additional units in the same category free (must be of equal or lesser value)",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "action": {
        "cart_items": {
          "discount": {
            "percentage_amount": "100"
          },
          "strategy": "LEAST_EXPENSIVE",
          "as_total": false,
          "include_items_considered_by_condition": false,
          "items": {
            "categories": [
              23
            ]
          },
          "quantity": 1
        }
      },
      "apply_once": true,
      "stop": false,
      "condition": {
        "cart": {
          "items": {
            "categories": [
              23
            ]
          },
          "minimum_quantity": 1
        }
      }
    }
  ],
  "notifications": [
    {
      "type": "UPSELL",
      "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
      "locations": [
        "CART_PAGE"
      ]
    },
    {
      "type": "ELIGIBLE",
      "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
      "locations": [
        "CART_PAGE"
      ]
    },
    {
      "type": "APPLIED",
      "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
      "locations": [
        "CART_PAGE"
      ]
    }
  ],
  "stop": false,
  "start_date": "2019-02-01T05:00:00+00:00",
  "status": "ENABLED"
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 12,
    "name": "Buy X units in (Category A) and get Y additional units in the same category free (must be of equal or lesser value)",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "percentage_amount": "100"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
              "categories": [
                36
              ]
            },
            "quantity": 1
          }
        },
        "apply_once": true,
        "stop": false,
        "condition": {
          "cart": {
            "items": {
              "categories": [
                36
              ]
            },
            "minimum_quantity": 1
          }
        }
      }
    ],
    "notifications": [
      {
        "type": "UPSELL",
        "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
        "locations": [
          "CART_PAGE"
        ]
      },
      {
        "type": "ELIGIBLE",
        "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
        "locations": [
          "CART_PAGE"
        ]
      },
      {
        "type": "APPLIED",
        "content": "<div>&nbsp;</div>\r\n<div>&nbsp;</div>",
        "locations": [
          "CART_PAGE"
        ]
      }
    ],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2019-02-01T05:00:00+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Buy three items in a category for the price of two (lowest priced item discounted)

#### Request

**`Example request`**

```json title="Example request"
{
  "name": "Buy three items in a category for the price of two (lowest priced item discounted)",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "apply_once": false,
      "condition": {
        "cart": {
          "items": {
            "categories": [
              21
            ]
          },
          "minimum_quantity": 2
        }
      },
      "action": {
        "cart_items": {
          "discount": {
            "percentage_amount": "100"
          },
          "strategy": "LEAST_EXPENSIVE",
          "items": {
            "categories": [
              21
            ]
          },
          "quantity": 1
        }
      }
    }
  ]
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 13,
    "name": "Buy three items in a category for the price of two (lowest priced item discounted)",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "percentage_amount": "100"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
              "categories": [
                36
              ]
            },
            "quantity": 1
          }
        },
        "apply_once": false,
        "stop": false,
        "condition": {
          "cart": {
            "items": {
              "categories": [
                36
              ]
            },
            "minimum_quantity": 2
          }
        }
      }
    ],
    "notifications": [],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2022-07-18T19:02:16+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Buy product X or items from category Y and get \$10 off items from category Z

#### Request

**`Example request`**

```json title="Example request"
{
  "name": "Buy product X or items from category Y and get $10 off items from category Z",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "apply_once": true,
      "condition": {
        "cart": {
          "items": {
            "or": [
              {
                "categories": [
                  1
                ]
              },
              {
                "products": [
                  1
                ]
              }
            ]
          },
          "minimum_quantity": 1
        }
      },
      "action": {
        "cart_items": {
          "discount": {
            "fixed_amount": 10
          },
          "items": {
            "categories": [
              31
            ]
          }
        }
      }
    }
  ]
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 14,
    "name": "Buy product X or items from category Y and get $10 off items from category Z",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "fixed_amount": "10"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
              "categories": [
                36
              ]
            }
          }
        },
        "apply_once": true,
        "stop": false,
        "condition": {
          "cart": {
            "items": {
              "or": [
                {
                  "categories": [
                    36
                  ]
                },
                {
                  "products": [
                    123
                  ]
                }
              ]
            },
            "minimum_quantity": 1
          }
        }
      }
    ],
    "notifications": [],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2022-07-18T19:16:26+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Buy three from category X, and get one from category Y free

#### Request

**`Example request`**

```json title="Example request"
{
  "name": "Buy three from category X and get one from category Y free",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "apply_once": false,
      "condition": {
        "cart": {
          "items": {
            "categories": [
              24
            ]
          },
          "minimum_quantity": 3
        }
      },
      "action": {
        "cart_items": {
          "discount": {
            "percentage_amount": 100
          },
          "items": {
            "categories": [
              24
            ]
          },
          "quantity": 1
        }
      }
    }
  ]
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 15,
    "name": "Buy three from category X and get one from category Y free",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "percentage_amount": "100"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
              "categories": [
                24
              ]
            },
            "quantity": 1
          }
        },
        "apply_once": false,
        "stop": false,
        "condition": {
          "cart": {
            "items": {
              "categories": [
                24
              ]
            },
            "minimum_quantity": 3
          }
        }
      }
    ],
    "notifications": [],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2022-07-18T19:57:54+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```

## Spend \$X from category X and get product Y free

#### Request

**`Example request`**

```json title="Example request"
{
  "name": "Buy $X from category X and get product Y free",
  "redemption_type": "AUTOMATIC",
  "rules": [
    {
      "apply_once": false,
      "condition": {
        "cart": {
          "items": {
            "categories": [
              19
            ]
          },
          "minimum_spend": 300
        }
      },
      "action": {
        "cart_items": {
          "discount": {
            "percentage_amount": 100
          },
          "items": {
            "products": [
              81
            ]
          },
          "quantity": 1
        }
      }
    }
  ]
}
```

#### Response

**`Example response`**

```json title="Example response"
{
  "data": {
    "id": 16,
    "name": "Buy $X from category X and get product Y free",
    "created_from": "api",
    "customer": {
      "group_ids": [],
      "minimum_order_count": 0,
      "excluded_group_ids": [],
      "segments": null
    },
    "rules": [
      {
        "action": {
          "cart_items": {
            "discount": {
              "percentage_amount": "100"
            },
            "strategy": "LEAST_EXPENSIVE",
            "add_free_item": true,
            "as_total": false,
            "include_items_considered_by_condition": false,
            "exclude_items_on_sale": false,
            "items": {
                "products": [
                  123
                ]
            },
            "quantity": 1
          }
        },
        "apply_once": false,
        "stop": false,
        "condition": {
          "cart": {
            "items": {
              "categories": [
                24
              ]
            },
            "minimum_spend": "300"
          }
        }
      }
    ],
    "notifications": [],
    "stop": false,
    "currency_code": "USD",
    "redemption_type": "AUTOMATIC",
    "shipping_address": null,
    "current_uses": 0,
    "max_uses": null,
    "start_date": "2022-07-18T20:07:24+00:00",
    "end_date": null,
    "status": "ENABLED",
    "schedule": null,
    "can_be_used_with_other_promotions": true
  },
  "meta": {}
}
```