# Update a promotion

Source: https://developers.swell.is/backend-api/promotions/update-a-promotion

Update an existing promotion using the ID that was returned when created.

## Arguments

- `id` (objectId, required): Unique identifier for the promotion.
- `active` (boolean): Indicates the promo is currently active. Note: this is not affected by `date_start` and `date_end`. Default: `false`.
- `date_end` (date): Date the promo ends and is no longer available. When defined, the promo will not be applied after this date.
- `name` (string): A short descriptive name of the promo.
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `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`.
- `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, required): List of discount rules 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_type` (enum, required): Type of discount amount to calculate. Can be `fixed` or `percent`. Possible values: `fixed`, `percent`. Default: `"fixed"`.
  - `value_fixed` (currency): Fixed discount applied when `value_type=fixed`.
  - `value_percent` (float): Percentage discount applied when `value_type=percent`.
  - `total_min` (currency): Minimum order total required for the rule to apply.
  - `discount_max` (currency): The maximum amount of a discount that can be redeemed.
  - `price_min` (currency): The mimimum amount of a discount that can be redeemed.
  - `quantity_min` (int): Minimum product quantity required for the rule to apply, applicable for category and product discounts.
  - `quantity_max` (int): Maximum product quantity for which the rule will apply, applicable for category and product discounts.
  - `product_id` (objectId): ID of the product to discount, if applicable.
  - `variant_id` (objectId): ID of the variant to discount, if applicable.
  - `shipment_service` (string): ID of the shipping service to discount, if applicable.
  - `category_id` (objectId): ID of the category to discount, if applicable.
  - `exclude_category_ids` (array of child_scalar): List of category IDs to exclude from discount, applicable to category discounts when several categories overlap.
  - `product` (product): Expandable link to the discounted product, if applicable.
  - `variant` (variant): Expandable link to the discounted variant, if applicable.
  - `category` (category): Expandable link to the discounted category, if applicable.
  - `exclude_categories` (exclude_categories): Expandable list of excluded categories, if applicable.
  - `buy_items` (array of object): List of items that need to be purchased before the promotion becomes eligible.
    - `product_id` (objectId): ID of the product that is tied to the promotion eligibility, if applicable.
    - `product` (product): Expandable link to the promotion-eligible product, if applicable.
    - `category_id` (objectId): ID of the category that is tied to the promotion eligibility, if applicable.
    - `category` (category): Expandable link to the promotion-eligible category, if applicable.
  - `get_items` (array of object): List of items eligible for promotion after designated products have been purchased.
    - `product_id` (objectId): ID of the product to discount, if applicable.
    - `product` (product): Expandable link to the discounted product, if applicable.
    - `category_id` (objectId): ID of the discounted category, if applicable.
    - `category` (category): Expandable link to the discounted category, if applicable.
- `exclusions` (array of object): List of exclusions considered when the promo is applied.
  - `type` (enum, required): The type of exclusion for the promotion. Can be either `product` or `category`. Possible values: `product`, `category`.
  - `product_id` (objectId): ID of the product to exclude from the discount, if applicable.
  - `category_id` (objectId): ID of the category to exclude from the discount, if applicable.
  - `product` (product): Expandable link to the excluded product, if applicable.
  - `category` (category): Expandable link to the excluded category, if applicable.
- `use_count` (int): Number of times the promo has been applied. Default: `0`.
- `limit_uses` (int): Maximum number of times the promo will be applied across all customers.
- `limit_account_uses` (int): Maximum number of times the promo will be applied by each customer account.
- `limit_account_groups` (array of child_scalar): List of customer account for which the promo will apply.

## Example request

`PUT /promotions/:id`

**cURL**

```sh
$ curl https://api.swell.store/promotions/60f199509111e7000000006b \
  -u store-id:secret-key \
  -d limit_uses=300 \
  -d active=true \
  -X PUT
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.put('/promotions/{id}', {
  id: '60f199509111e7000000006b',
  limit_uses: 300,
  active: true
});
```

**PHP**

```php
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->put('/promotions/{id}', [
  'id' => '60f199509111e7000000006b',
  'limit_uses' => 300,
  'active' => true
]);
```

## 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
}
```
