# Create a coupon generation

Source: https://developers.swell.is/backend-api/coupon-generations/create-a-coupon-generation

Create a new coupon generation.

## Arguments

- `id` (objectId): ID of the coupon generation.
- `count` (int, required): The number of coupon codes generated in the generation. Minimum of 0 and maximum of 1000. Default: `0`.
- `parent_id` (objectId, required): ID of the parent coupon.
- `codes` (Coupon code): Expandable link to the coupon code.
- `complete` (boolean): Indicates that the coupon code generation is complete. Default: `false`.
- `date_created` (date, auto): Date and time the coupon generation was created.
- `date_updated` (date, auto): Date and time the coupon generation was last updated.
- `error` (string): Indicates if there was an error with the coupon code generation.
- `parent` (Coupon): Expandable link to the parent coupon.
- `pattern` (string): Specifies the code pattern for generated coupons.
- `pattern_type` (string): Determines the pattern type for the codes generated, which can be either `default` or `custom`. Specify the pattern when using `custom`.

## Example request

`POST /coupons:generations`

**cURL**

```sh
$ curl https://api.swell.store/coupons:generations \
  -u store-id:secret-key \
	-d pattern_type:"default" \
	-d count:10 \
```

**Node**

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

await swell.post('/coupons:generations', {
pattern_type: default
count: 10
});
```

**PHP**

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

$swell->post('/coupons:generations', [
'pattern_type' => 'default'
'count' => 10
]);
```

## Example response

```json
{
  "complete": true,
  "count": 1000,
  "date_created": "2015-09-02T20:57:03.441Z",
  "date_updated": "2015-09-02T20:57:20.033Z",
  "parent_id": "559c5799bcb1de1d1c4821da",
  "pattern": "TABATHA-{0000000}",
  "pattern_type": "custom",
  "id": "55e7629f5c0dfa1e3c2dd4c1"
},
```
