> For the complete documentation index, see [llms.txt](https://docs.ecwid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecwid.com/discounts-and-tips/customize-discounts/set-up-buy-x-get-y-promotions.md).

# Set up "Buy X - Get Y" promotions

With promotions, you can set up **Buy X - Get Y** promotions in your store. For example, if customers add 3 any pizzas to the cart, they get a 100% discount on up to 2 drinks of their choice.

{% hint style="info" %}
If you don't yet have an app for Ecwid API access, start with the following [instructions](https://docs.ecwid.com/spaces/uOzT5egoVTAjMJwRuMQT/pages/IhHAmacGKQdbD0Fe0IUw#step-2.-get-your-first-application).
{% endhint %}

### Add products from category X to receive free products from category Y

Request example for a new promotion: "**Add 3 pizzas to the cart and receive two free drinks**"

```http
POST /api/v3/STOREID/promotions
Host: app.ecwid.com
Content-Type: application/json
Authorization: Bearer secret_token

{
    "name": "Free drink for any 3 pizzas",
    "discountBase": "ITEM",
    "discountType": "PERCENT",
    "amount": 100,
    "enabled": true,
    "triggers": {
        "minProductQuantityInCart": 3,
        "categories": [862076252]
    },
    "targets": {
        "maxDiscountedProductQuantity": 2,
        "categories": [375620372]
    }
}
```

where:

* `"discountBase": "ITEM"` states that the discount from the promotion only affects products defined in the `targets` object.
* `triggers` object contains trigger conditions – a minimum of 3 products added to the cart from the category ID 862076252 (**pizzas** in our case).
* `targets` object defines that the discount only applies to the first two products from category ID 375620372. Products from other categories or the third and later products from category ID 375620372 won't be affected by the discount (**drinks** in our case).

Change `STOREID` with your store ID, and the `secret_token` with the secret access token of your app.

### Add product X and receive discount on product Y

Request example for a new promotion: **"Buy muffin and get 50% discount on latte"**

```http
POST /api/v3/STOREID/promotions
Host: app.ecwid.com
Content-Type: application/json
Authorization: Bearer secret_token

{
    "name": "50% discount on latte",
    "discountBase": "ITEM",
    "discountType": "PERCENT",
    "amount": 50,
    "enabled": true,
    "triggers": {
        "minProductQuantityInCart": 1,
        "products": [102039482]
    },
    "targets": {
        "maxDiscountedProductQuantity": 1,
        "products": [236754267]
    }
}
```

where:

* `"discountBase": "ITEM"` states that the discount from the promotion only affects products defined in the `targets` object.
* `triggers` object contains trigger conditions – a minimum of 1 product ID 102039482 in the cart (**muffin** in our case).
* `targets` object limits the discount only to product ID 236754267 (**latte** in our case).

Change `STOREID` with your store ID, and the `secret_token` with the secret access token of your app.

### See also

[API reference on creating promotions](https://docs.ecwid.com/api-reference/rest-api/discounts/promotions/create-promotion.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecwid.com/discounts-and-tips/customize-discounts/set-up-buy-x-get-y-promotions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
