> ## Documentation Index
> Fetch the complete documentation index at: https://developers-docs.easyorders.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Coupons

> Create and manage the store's coupons: by code or automatic, the four discount types, and what they apply to.

Scopes: `read_discounts` to read, `write_discounts` to change (it includes `read_discounts`).

## The coupon

```json theme={"dark"}
{
  "id": "4b7e2c1a-9d3f-4e6b-8a5c-2f1d0e9c8b7a",
  "method": "code",
  "code": "summer15",
  "title": "",
  "discount_type": "amount_off_products",
  "value_type": "percentage",
  "value": 15,
  "min_order_amount": 0,
  "min_quantity": 0,
  "max_discount_amount": 200,
  "usage_limit": 500,
  "usage_count": 37,
  "is_active": true,
  "starts_at": null,
  "expires_at": "2027-09-01T00:00:00Z",
  "applies_to": "specific_categories",
  "buy_quantity": 0,
  "buy_requirement_type": "quantity",
  "buy_amount": 0,
  "get_quantity": 0,
  "get_value_type": "free",
  "get_value": 0,
  "max_uses_per_order": 0,
  "max_shipping_discount": 0,
  "exclude_shipping_over": 0,
  "combines_with_product": false,
  "combines_with_order": false,
  "combines_with_shipping": true,
  "applicable_items": [
    { "item_type": "category", "item_id": "8d2f4b6a-1c3e-4a5b-9d7f-0e1a2b3c4d5e", "is_buy_item": false }
  ],
  "created_at": "2026-12-01T09:00:00Z",
  "updated_at": "2026-12-03T14:30:00Z"
}
```

A coupon always comes with its `applicable_items`. `usage_count` is how many orders used it: read only, and sending it answers `400`. The store's coupon settings, such as whether the storefront shows the coupon box, are not part of this API.

## Code or automatic

* **`code`**: the shopper types the code at checkout. The code is trimmed and saved **lowercased**, so `SUMMER15` is saved as `summer15`. Up to 64 characters: letters of any language, digits, `-` and `_`. It is unique among the store's coupons, letter case aside: a taken code answers `409 code_taken`.
* **`automatic`**: applied without a code. It has no code (`""`) and needs a `title`, which the storefront shows.

`title` is one line of plain text, up to 255 characters, with no `<`.

## Discount types

| `discount_type` | What it takes |
| - | - |
| `amount_off_products` | `value`, above 0: an amount, or a percentage up to 100 when `value_type` is `percentage`. |
| `amount_off_order` | `value`, as above. |
| `free_shipping` | No rule on `value`. |
| `buy_x_get_y` | Buy items and get items (see below). |

A `buy_x_get_y` coupon:

* applies to `specific_products` or `specific_categories`, with at least one buy item (`is_buy_item: true`) and one get item;
* needs `buy_quantity` above 0 when `buy_requirement_type` is `quantity` (the default), or `buy_amount` above 0 when it is `amount`;
* needs `get_quantity` above 0;
* gives the get items free (`get_value_type: "free"`, the default), or off by `get_value`, above 0, as a `percentage` (up to 100) or a `fixed` amount.

`combines_with_product`, `combines_with_order` and `combines_with_shipping` say which kinds of coupon it can be used with: product coupons (`amount_off_products`, `buy_x_get_y`), order coupons (`amount_off_order`) and shipping coupons (`free_shipping`). Two coupons combine only when each allows the other's kind.

## What it applies to

`applies_to` is `all` (the default), `specific_products` or `specific_categories`. The last two need `applicable_items`, each one:

| `item_type` | `item_id` |
| - | - |
| `product` | A product of the store, with every variant of it. |
| `variant` | One variant of a product of the store. |
| `category` | A category of the store. |

* At most **100** items, none twice.
* Each must be a live product, variant or category of **this store**. One that is not answers `422` on its `item_id`, with its type as the rule (`product`, `variant` or `category`).
* Items read back in one order: buy items first, then by type and ID.

## Rules

Each field is checked on its own: amounts from 0 to 100,000,000 with at most 4 decimals, counts (`min_quantity`, `buy_quantity`, `get_quantity`, `max_uses_per_order`) from 0 to 1,000,000, `usage_limit` from 0 to 1,000,000,000 (`0` is no limit), and dates from 2000 to 2100. Then the whole coupon must hold together:

* a `code` coupon has a code; an `automatic` one has a `title` and no code;
* the value rules of its [discount type](#discount-types);
* `specific_products` and `specific_categories` have applicable items;
* `starts_at` is not after `expires_at`.

A broken rule answers `422 validation_failed`, naming every field. See [Errors](https://developers-docs.easyorders.ai/concepts/errors.md).

On create, only `method` and `discount_type` are required. The rest take their defaults: active, a `fixed` value, applies to `all`, a `quantity` buy requirement, free get items, and zero, `false` or no date for everything else.

## Updating

[Update a coupon](https://developers-docs.easyorders.ai/api-reference/coupons/update-a-coupon.md) changes only the fields you send, and checks the [rules](#rules) on the coupon it leaves: the saved one with your changes. So a change that would break the coupon is refused even when each field is fine on its own. To turn a code coupon `automatic`, send `"code": ""` and a `title` with it.

* **Clearing a date takes an explicit `null`**: `"expires_at": null` removes the expiry, `"starts_at": null` the start. Leaving the field out keeps it. Every other field refuses `null`.
* `applicable_items` replaces all the items when you send it; `[]` removes them.

## Deleting

[Delete a coupon](https://developers-docs.easyorders.ai/api-reference/coupons/delete-a-coupon.md) works as in the dashboard: the coupon stops applying and disappears from lists and reads (`404`), while orders that used it keep their discount. Its code becomes free for a new coupon.

## Changes show at once

The storefront does not cache coupons, so a change takes effect at once. Coupon changes send no events.

Create with an [`Idempotency-Key`](https://developers-docs.easyorders.ai/concepts/idempotency) to retry safely. Lists are [paginated](https://developers-docs.easyorders.ai/concepts/pagination.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.