# Coupons

Source: https://developers.swell.is/backend-api/coupons

Coupons are a way to offer customers a discount with a coupon code. A coupon can have several discounts and exceptions. For example, a coupon discount can apply to a whole order, to particular categories, to individual products, or to shipping methods. A coupon can be limited to a maximum number of uses, by specific customer groups, by expiration date, and more.

## The coupon model

### Fields

- `id` (objectId): Unique identifier for the coupon.
- `name` (string, required): A short descriptive name of the coupon.
- `active` (boolean): Indicates the coupon is currently active. Note: this is not affected by `date_valid` and `date_expired`. Default: `false`.
- `active_generations` (Coupon generation): List of coupon generations that are active.
- `codes` (array of Codes): Expandable list of codes used to identify the coupon.
- `currency` (string): Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
- `date_created` (date): Date and time the coupon was created.
- `date_expired` (date): Date the coupon is considered expired and no longer available for use. When defined, the coupon will not be valid after this date.
- `date_updated` (date): Date and time the coupon was last updated.
- `date_valid` (date): Date the coupon is first available for use. When defined, the coupon will not be valid until after this date and before `date_expired`.
- `description` (string): A brief description of the coupon, as it may be displayed to customers.
- `discount_group` (string): ID of the discount group the coupon 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.
  - `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 value to calculate discount amount. 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`.
  - `category_id` (objectId): ID of the category to discount, if applicable.
  - `category` (category): Expandable link to the discounted category, 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.
  - `exclude_categories` (exclude_categories): Expandable list of excluded categories, if applicable.
  - `price_min` (currency): Minimum product price required for the rule to apply, applicable for category and product discounts.
  - `product_id` (objectId): ID of the product to discount, if applicable.
  - `product` (product): Expandable link to the discounted product, if applicable.
  - `quantity_add` (int): Quantity of the product to add to cart, if applicable.
  - `quantity_max` (int): Maximum product quantity required for the rule to 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.
  - `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.
  - `variant` (variant): Expandable link to the discounted variant, if applicable.
  - `buy_items` (array of object): Items required to be purchased in order to receive the coupon.
    - `product_id` (objectId): Unique identifier for the product.
    - `product` (product): Expandable link to the product.
    - `category_id` (objectId): Unique identifier for the category.
    - `category` (category, required): Expandable link to the category.
  - `get_items` (array of object): Eligible discounted items available once a coupon's `buy_items` requirements are met.
    - `product_id` (objectId): Unique identifier for the product.
    - `product` (product): Expandable link to the product.
    - `category_id` (objectId): Unique identifier for the category.
    - `category` (category): Expandable link to the category.
  - `get_total` (boolean): Indicates whether the `get_items` promotion requirements have been met.
  - `discount_max` (currency): Maximum redeemable discount amount for the coupon.
- `generations` (array of Generations): List of coupon generations.
- `limit_code_uses` (int): Maximum number of times each coupon code can be applied. Mainly used with multiple codes.
- `limit_uses` (int): Maximum number of times the coupon can be applied across all customers.
- `limit_account_uses` (int): Maximum number of times the coupon can be used by each customer account.
- `limit_account_groups` (array of account_groups): List of customer account groups allowed to use the coupon.
- `limit_account_segments` (array of string): List of account segments for which the coupon is avaialble.
- `limit_subscription_uses` (int): Maximum number of invoices the promotion may be applied to for a subscription.
- `multi_codes` (boolean): Indicates the coupon is identified by multiple coupon codes. Default: `false`.
- `orders` (Order): Expandable list of orders that have applied the coupon.
- `subscriptions` (Subscription): Expandable list of subscriptions that have applied the coupon.
- `use_count` (int): Number of times the coupon has been used.
- `uses` (array of Uses): Expandable list of coupon code usage records.

### Example response

```json
{
  "id": "60f199509111e70000000015",
  "name": "10% Off Winter Jacket Sale",
  "active": true,
  "codes": [
    {
      "code": "WINTER10"
    }
  ],
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.100Z",
  "date_expired": "2018-03-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.100Z",
  "date_valid": "2018-11-01T00:00:00.000Z",
  "description": "Save 10% on all Winter Jackets for a limited time only.",
  "discount_group": null,
  "discounts": [
    {
      "type": "category",
      "category_id": "5a97242bc65396a875c2d381",
      "value_type": "percent",
      "value_fixed": 10
    }
  ],
  "limit_account_uses": 3,
  "limit_code_uses": 10,
  "limit_uses": 300,
  "multi_codes": false,
  "use_count": 184
}
```


## Create a coupon

Create a new coupon.

### Arguments

- `name` (string, required): A short descriptive name of the coupon.
- `active` (boolean): Indicates the coupon is currently active. Note: this is not affected by `date_valid` and `date_expired`. Default: `false`.
- `codes` (array of Codes, required): Expandable list of codes used to identify the coupon.
- `date_expired` (date): Date the coupon is considered expired and no longer available for use. When defined, the coupon will not be valid after this date.
- `description` (string): A brief description of the coupon, as it may be displayed to customers.
- `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 minimum 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.
  - `quantity_add` (int): Quantity of the product to add to cart, if applicable.
  - `shipment_service` (string): ID of the shipping service to discount, if applicable.
  - `category_id` (objectId): Unique identifier for the category.
  - `exclude_category_ids` (array of child_scalar): List of category IDs excluded by the coupon.
  - `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 link to categories excluded from the promotion, if applicable.
  - `buy_items` (array of object): Items required to be purchased in order to receive the coupon.
    - `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): Eligible discounted items available once a coupon's `buy_items` requirements are met.
    - `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.
- `multi_codes` (boolean): Indicates the coupon is identified by multiple coupon codes. Default: `false`.
- `active_generations` (Coupon generation): List of coupon generations that are active.
- `currency` (string): Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) in uppercase. Defaults to base currency.
- `date_valid` (date): Date the coupon is first available for use. When defined, the coupon will not be valid until after this date and before `date_expired`.
- `discount_group` (string): ID of the discount group the coupon 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.
- `generations` (array of Generations): List of coupon generations.
- `limit_account_groups` (array of child_scalar): List of customer account groups allowed to use the coupon.
- `limit_account_segments` (array of child_scalar): List of account segments for which the coupon is avaialble.
- `limit_account_uses` (int): Maximum number of times the coupon can be used by each customer account.
- `limit_code_uses` (int): Maximum number of times each coupon code can be applied. Mainly used with multiple codes.
- `limit_subscription_uses` (int): Maximum number of invoices the promotion may be applied to for a subscription.
- `limit_uses` (int): Maximum number of times the coupon can be applied across all customers.
- `orders` (Order): Expandable list of orders that have applied the coupon.
- `subscriptions` (Subscription): Expandable list of subscriptions that have applied the coupon.
- `use_count` (int): Number of times the coupon has been used.
- `uses` (Promotion Use): Expandable list of coupon code usage records.

### Example request

`POST /coupons`

**cURL**

```bash
$ curl https://api.swell.store/coupons \
  -u store-id:secret-key \
  -d codes[0][code]=WINTER10 \
  -d discounts[0][type]=category \
  -d discounts[0][category_id]=5a97242bc65396a875c2d381 \
  -d discounts[0][value_type]=percent \
  -d discounts[0][value_fixed]=10 \
  -d name="10% Off Winter Jacket Sale" \
  -d active=true \
  -d date_expired=2018-03-01T00:00:00.000Z \
  -d description="Save 10% on all Winter Jackets for a limited time only." \
  -d multi_codes=false \
```

**Node**

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

await swell.post('/coupons', {
  codes: [
    {
      code: 'WINTER10'
    }
  ],
  discounts: [
    {
      type: 'category',
      category_id: '5a97242bc65396a875c2d381',
      value_type: 'percent',
      value_fixed: 10
    }
  ],
  name: '10% Off Winter Jacket Sale',
  active: true,
  date_expired: '2018-03-01T00:00:00.000Z',
  description: 'Save 10% on all Winter Jackets for a limited time only.',
  multi_codes: false
});
```

**PHP**

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

$swell->post('/coupons', [
  'codes' => [
    [
      'code' => 'WINTER10'
    ]
  ],
  'discounts' => [
    [
      'type' => 'category',
      'category_id' => '5a97242bc65396a875c2d381',
      'value_type' => 'percent',
      'value_fixed' => 10
    ]
  ],
  'name' => '10% Off Winter Jacket Sale',
  'active' => true,
  'date_expired' => '2018-03-01T00:00:00.000Z',
  'description' => 'Save 10% on all Winter Jackets for a limited time only.',
  'multi_codes' => false
]);
```

### Example response

```json
{
  "id": "60f199509111e70000000015",
  "name": "10% Off Winter Jacket Sale",
  "active": true,
  "codes": [
    {
      "code": "WINTER10"
    }
  ],
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.100Z",
  "date_expired": "2018-03-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.100Z",
  "date_valid": "2018-11-01T00:00:00.000Z",
  "description": "Save 10% on all Winter Jackets for a limited time only.",
  "discount_group": null,
  "discounts": [
    {
      "type": "category",
      "category_id": "5a97242bc65396a875c2d381",
      "value_type": "percent",
      "value_fixed": 10
    }
  ],
  "limit_account_uses": 3,
  "limit_code_uses": 10,
  "limit_uses": 300,
  "multi_codes": false,
  "use_count": 184
}
```


## Retrieve a coupon

Retrieve an existing coupon using the ID that was returned when created.

### Arguments

- `id` (objectId, required): The ID of the coupon to retrieve.
- `expand` (string): Expanding link fields and child collections is performed using the expand argument.

  - For example, `expand=account` would return a related customer account if one exists.

  When the field represents a collection, you can specify the query limit.

  - For example, `expand=variants:10` would return up to 10 records of the variants collection.

  See [expanding ](https://developers.swell.is/backend-api/querying/expanding)for more details.
- `fields` (string): Return only the specified fields in the result. For example `fields=name,slug` would return only the fields `name` and `slug` in the response. Supports nested object and array fields using dot-notation, for example, `items.product_id`. The category `id` is always returned.
- `include` (string): Include one or more arbitrary queries in the response, possibly related to the main query.

  See [including ](https://developers.swell.is/backend-api/querying/including)for more details.

### Example request

`GET /coupons/:id`

**cURL**

```bash
$ curl https://api.swell.store/coupons/60f199509111e7000000001b \
  -u store-id:secret-key
```

**Node**

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

await swell.get('/coupons/{id}', {
  id: '60f199509111e7000000001b'
});
```

**PHP**

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

$swell->get('/coupons/{id}', [
  'id' => '60f199509111e7000000001b'
]);
```

### Example response

```json
{
  "id": "60f199509111e7000000001b",
  "name": "10% Off Winter Jacket Sale",
  "active": true,
  "codes": [
    {
      "code": "WINTER10"
    }
  ],
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.100Z",
  "date_expired": "2018-03-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.100Z",
  "date_valid": "2018-11-01T00:00:00.000Z",
  "description": "Save 10% on all Winter Jackets for a limited time only.",
  "discount_group": null,
  "discounts": [
    {
      "type": "category",
      "category_id": "5a97242bc65396a875c2d381",
      "value_type": "percent",
      "value_fixed": 10
    }
  ],
  "limit_account_uses": 3,
  "limit_code_uses": 10,
  "limit_uses": 300,
  "multi_codes": false,
  "use_count": 184
}
```


## Update a coupon

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

### Arguments

- `id` (objectId, required): Unique identifier for the coupon.
- `active` (boolean): Indicates the coupon is currently active. Note: this is not affected by `date_valid` and `date_expired`. Default: `false`.
- `date_expired` (date): Date the coupon is considered expired and no longer available for use. When defined, the coupon will not be valid after this date.
- `name` (string): A short descriptive name of the coupon.
- `codes` (array of Codes, required): Expandable list of codes used to identify the coupon.
- `currency` (string): Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) in uppercase. Defaults to base currency.
- `date_valid` (date): Date the coupon is first available for use. When defined, the coupon will not be valid until after this date and before `date_expired`.
- `description` (string): A brief description of the coupon, as it may be displayed to customers.
- `discount_group` (string): ID of the discount group the coupon 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 minimum 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.
  - `quantity_add` (int): Quantity of the product to add to cart, if applicable.
  - `shipment_service` (string): ID of the shipping service to discount, if applicable.
  - `category_id` (objectId)
  - `exclude_category_ids` (array of child_scalar)
  - `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 link to categories excluded from the promotion, 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.
- `limit_account_groups` (array of child_scalar): List of customer account groups allowed to use the coupon.
- `limit_account_uses` (int): Maximum number of times the coupon can be used by each customer account.
- `limit_subscription_uses` (int): Maximum number of invoices the promotion may be applied to for a subscription.
- `limit_code_uses` (int): Maximum number of times each coupon code can be applied. Mainly used with multiple codes.
- `limit_uses` (int): Maximum number of times the coupon can be applied across all customers.
- `multi_codes` (boolean): Indicates the coupon is identified by multiple coupon codes. Default: `false`.
- `use_count` (int): Number of times the coupon has been used.

### Example request

`PUT /coupons/:id`

**cURL**

```bash
$ curl https://api.swell.store/coupons/60f199509111e70000000015 \
  -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('/coupons/{id}', {
  id: '60f199509111e70000000015',
  limit_uses: 300,
  active: true
});
```

**PHP**

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

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

### Example response

```json
{
  "id": "60f199509111e70000000015",
  "name": "10% Off Winter Jacket Sale",
  "active": true,
  "codes": [
    {
      "code": "WINTER10"
    }
  ],
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.100Z",
  "date_expired": "2018-03-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.100Z",
  "date_valid": "2018-11-01T00:00:00.000Z",
  "description": "Save 10% on all Winter Jackets for a limited time only.",
  "discount_group": null,
  "discounts": [
    {
      "type": "category",
      "category_id": "5a97242bc65396a875c2d381",
      "value_type": "percent",
      "value_fixed": 10
    }
  ],
  "limit_account_uses": 3,
  "limit_code_uses": 10,
  "limit_uses": 300,
  "multi_codes": false,
  "use_count": 184
}
```


## List all coupons

Return a list of coupons.

### Arguments

- `expand` (string): Expand link fields and child collections by using the expand argument.

  - For example, `expand=account` would return a related customer account if one exists.

  When the field represents a collection, you can specify the query limit.

  - For example, `expand=variants:10` would return up to 10 records of the variants collection.

  See [expanding](https://developers.swell.is/backend-api/querying/expanding) for more details.
- `fields` (string): Returns only the specified fields in the result.

  - For example `fields=name,slug` would return only the fields `name` and `slug` in the response.

  Supports nested object and array fields using dot-notation.

  - For example, `items.product_id`. The product `id` is always returned.
- `include` (object): Include one or more arbitrary queries in the response which are potentially related to the main query.

  See [including](https://developers.swell.is/backend-api/querying/including) for more details.
- `limit` (int): Limit the number of records returned, ranging between `1` and `1000`. Defaults to `15`. Default: `15`.
- `page` (int): The page number of results to return given the specified or default `limit`.
- `search` (string): A text search is performed using the search argument. Searchable fields are defined by the model.

  - For example, `search=red` would return records containing the word "red" anywhere in the defined text fields.

  See [searching](https://developers.swell.is/backend-api/querying/searching) for more details.
- `sort` (string): Expression to sort results by using a format similar to a SQL sort statement.

  - For example, `sort=name asc` would return records sorted by name ascending.

  See [sorting](https://developers.swell.is/backend-api/querying/sorting) for more details.
- `where` (object): An object with criteria to filter the result.

  - For example, `active=true` would return records containing a field `active` with the value `true`.

  It's also possible to use query operators, for example, `$eq`, `$ne`, `$gt`, and more.

  See [querying](https://developers.swell.is/backend-api/querying) for more details.

### Example request

`GET /coupons`

**cURL**

```bash
$ curl https://api.swell.store/coupons?limit=25&page=1 \
  -u store-id:secret-key \
  -G
```

**Node**

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

await swell.get('/coupons', {
  where: {
    active: true
  },
  limit: 25,
  page: 1
});
```

**PHP**

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

$swell->get('/coupons', [
  'where' => [
    'active' => true
  ],
  'limit' => 25,
  'page' => 1
]);
```

### Example response

```json
{
  "count": 51,
  "results": [
    {
      "id": "60f199509111e70000000015",
      "name": "10% Off Winter Jacket Sale",
      "active": true,
      "codes": [
        {
          "code": "WINTER10"
        }
      ],
      "currency": "USD",
      "date_created": "2021-07-16T14:36:00.100Z",
      "date_expired": "2018-03-01T00:00:00.000Z",
      "date_updated": "2021-07-16T14:36:00.100Z",
      "date_valid": "2018-11-01T00:00:00.000Z",
      "description": "Save 10% on all Winter Jackets for a limited time only.",
      "discount_group": null,
      "discounts": [
        {
          "type": "category",
          "category_id": "5a97242bc65396a875c2d381",
          "value_type": "percent",
          "value_fixed": 10
        }
      ],
      "limit_account_uses": 3,
      "limit_code_uses": 10,
      "limit_uses": 300,
      "multi_codes": false,
      "use_count": 184
    },
    {...},
    {...}
  ],
  "page": 1,
  "page_count": 3,
  "limit": 25,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 50
    },
    "3": {
      "start": 51,
      "end": 51
    }
  }
}
```


## Delete a coupon

Delete a coupon permanently.

### Arguments

- `id` (objectId, required): The ID of the coupon to delete.

### Example request

`DELETE /coupons/:id`

**cURL**

```bash
$ curl https://api.swell.store/coupons/60f199509111e70000000021 \
  -u store-id:secret-key \
  -X DELETE
```

**Node**

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

await swell.delete('/coupons/{id}', {
  id: '60f199509111e70000000021'
});
```

**PHP**

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

$swell->delete('/coupons/{id}', [
  'id' => '60f199509111e70000000021'
]);
```

### Example response

```json
{
  "id": "60f199509111e70000000021",
  "name": "10% Off Winter Jacket Sale",
  "active": true,
  "codes": [
    {
      "code": "WINTER10"
    }
  ],
  "currency": "USD",
  "date_created": "2021-07-16T14:36:00.100Z",
  "date_expired": "2018-03-01T00:00:00.000Z",
  "date_updated": "2021-07-16T14:36:00.100Z",
  "date_valid": "2018-11-01T00:00:00.000Z",
  "description": "Save 10% on all Winter Jackets for a limited time only.",
  "discount_group": null,
  "discounts": [
    {
      "type": "category",
      "category_id": "5a97242bc65396a875c2d381",
      "value_type": "percent",
      "value_fixed": 10
    }
  ],
  "limit_account_uses": 3,
  "limit_code_uses": 10,
  "limit_uses": 300,
  "multi_codes": false,
  "use_count": 184
}
```

