# Create a coupon use

Source: https://developers.swell.is/backend-api/coupon-uses/create-a-coupon-use

Create a new coupon use.

## Arguments

- `id` (objectId): Unique identifier for the coupon use.
- `order_id` (objectId): Unique identifier for the order.
- `subscription_id` (objectId): ID of the subscription that spawned the order, if applicable.
- `account_id` (objectId): Unique identifier for the account.
- `parent_id` (objectId, required): ID of the parent coupon.
- `code` (string, required): Coupon code applied to the use.
- `code_id` (objectId, required): The ID of the coupon code.
- `date_created` (date): Date and time the coupon use was created.
- `date_updated` (date): Date and time the coupon use was last updated.
- `order` (Order): Expandable link to the order.
- `parent` (Coupon): Expandable link to the coupon.
- `subscription` (Subscription): Expandable link to the subscription.

## Example request

`POST /coupons:uses`

**cURL**

```sh
$ curl https://api.swell.store/coupons:uses \
  -u store-id:secret-key \
  -d parent_id=59c189016094a888436aee7f \
  -d code=WELLMET \
  -d code_id=59c2c4a4c339b09853c6799c \
  -d account_id=6081ae962717ed7a555e0d29 \
  -d subscription_id=623b3c95e75dd3013d6eac48
```

**Node**

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

await swell.post('/coupons:uses', {
  parent_id: '59c189016094a888436aee7f',
  code: 'WELLMET',
  code_id: '59c2c4a4c339b09853c6799c',
  account_id: '6081ae962717ed7a555e0d29',
  subscription_id: '623b3c95e75dd3013d6eac48'
});
```

**PHP**

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

$swell->post('/coupons:uses', [
  'parent_id' => '59c189016094a888436aee7f',
  'code' => 'WELLMET',
  'code_id' => '59c2c4a4c339b09853c6799c',
  'account_id' => '6081ae962717ed7a555e0d29',
  'subscription_id' => '623b3c95e75dd3013d6eac48'
]);
```

## Example response

```json
{
  "parent_id": "59c189016094a888436aee7f",
   "code": "DAGOTHWAVE",
   "code_id": "59c2c4a4c339b09853c6799c",
   "account_id": "60d61bd6575eaa344eab5c83",
   "order_id": "624319a0178e7f6c57bb3c49",
   "date_created": "2022-05-11T18:00:43.894Z",
   "id": "627bf9cb6d9c840012204a8a"
},
```
