# The promotion model

Source: https://developers.swell.is/backend-api/promotions/the-promotion-model

## Fields

- `id` (objectId): Unique identifier for the promotion.
- `name` (string, required): A short descriptive name of the promo.
- `active` (boolean): Indicates the promo is currently active. Note: this is not affected by `date_start` and `date_end`. Default: `false`.
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `date_created` (date, auto): Date and time the promotion was created.
- `date_end` (date): Date the promo ends and is no longer available. When defined, the promo will not be applied after this date.
- `date_start` (date): Date the promo is first available. When defined, the promo will not be valid until after this date and before `date_end`.
- `date_updated` (date, auto): Date and time the promotion was last updated.
- `description` (string): A brief description of the promo, as it may be displayed to customers.
- `discount_group` (string): ID of the discount group the promo belongs to, if applicable, as defined in discount settings. Used to ensure only one set of discount rules can apply across a number of coupons and promotions.
- `discounts` (array of object): List of discount rules to apply.
  - `buy_items` (array of object): Items required to be purchased in order to receive the promotion.
    - `category_id` (objectId): Unique identifier for the category.
    - `category` (category): Expandable link to the category.
    - `product_id` (objectId): Unique identifier for the product.
    - `product` (product): Expandable link to the product.
  - `category` (category): Expandable link to the discounted category, if applicable.
  - `category_id` (objectId): ID of the category to discount, if applicable.
  - `exclude_categories` (exclude_categories): Expandable list of excluded categories, if applicable.
  - `exclude_category_ids` (array of category_id): List of category IDs to exclude from discount, applicable to category discounts when several categories overlap.
  - `get_items` (array of object): Eligible discounted items available once promotion's `buy_items` requirements are met.
    - `category_id` (objectId): Unique identifier for the category.
    - `category` (category): Expandable link to the category.
    - `product_id` (objectId): Unique identifier for the product.
    - `product` (product): Expandable link to the product.
  - `get_total` (boolean): Indicates whether the `get_items` promotion requirements have been met.
  - `price_min` (currency): Minimum product price required for the rule to apply, applicable for category and product discounts.
  - `product` (product): Expandable link to the discounted product, if applicable.
  - `product_id` (objectId): ID of the product to discount, if applicable.
  - `quantity_max` (int): Maximum product quantity for which the rule will apply, applicable for category and product discounts.
  - `quantity_min` (int): Minimum product quantity required for the rule to apply, applicable for category and product discounts.
  - `shipment_service` (string): ID of the shipping service to discount, if applicable.
  - `total_min` (currency): Minimum order total required for the rule to apply.
  - `type` (enum): Type of discount to apply. Can be `total`, `product`, `category` or `shipment`. Possible values: `total`, `shipment`, `product`, `category`, `buy_get`. Default: `"total"`.
  - `value_fixed` (currency): Fixed discount applied when `value_type=fixed`.
  - `value_percent` (float): Percentage discount applied when `value_type=percent`.
  - `variant_id` (objectId): ID of the variant to discount, if applicable.
  - `value_type` (enum, required): Type of discount amount to calculate. Can be `fixed` or `percent`. Possible values: `fixed`, `percent`. Default: `"fixed"`.
  - `purchase_option` (enum): Purchase option the discount applies to. Possible values: `standard`, `subscription`, `subscription_plan`.
  - `subscription_plan_id` (objectId): ID of the subscription plan the discount applies to, when `purchase_option` is `subscription_plan`.
  - `variant` (variant): Expandable link to the discounted variant, if applicable.
- `exclusions` (array of object): List of exclusions considered when the promo is applied.
  - `category_id` (objectId): ID of the category to exclude from the promo.
  - `category` (category): Expandable link to the category excluded from the promo.
  - `product_id` (objectId): ID of the product to exclude from the promo.
  - `product` (product): Expandable link to the product excluded from the promo.
  - `type` (enum, required): Type of exclusion. Can be `product` or `category`. Possible values: `product`, `category`.
- `limit_account_groups` (array of account_groups): List of customer account for which the promo will apply.
- `limit_account_uses` (int): Maximum number of times the promo will be applied by each customer account.
- `limit_uses` (int): Maximum number of times the promo will be applied across all customers.
- `orders` (Order): Expandable list of orders that have applied the promo.
- `subscriptions` (Subscription): Expandable list of subscriptions that have applied the promo.
- `use_count` (int, auto): Number of times the promo has been applied. Default: `0`.
- `uses` (array of Uses): Expandable list of promotion use records.

## Example response

```json
{
  "id": "60f199509111e7000000006b",
  "name": "15% Off Store Wide Sale",
  "active": true,
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.386Z",
  "date_end": "2018-03-01T00:00:00.000Z",
  "date_start": "2018-11-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.386Z",
  "description": "Save 15% store wide for a limited time only.",
  "discounts": [
    {
      "type": "total",
      "value_type": "percent",
      "value_fixed": 15
    }
  ],
  "limit_account_uses": 3,
  "limit_uses": 300,
  "use_count": 142
}
```
