> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ecomail.cz/llms.txt
> Use this file to discover all available pages before exploring further.

# Create or overwrite discount coupons

> Create new discount coupons and overwrite existing ones in a default or specific folder.

> [!NOTE]
>
> An existing coupon is overwritten completely. The request sets `valid_until`, `type`, `value`, `currency`, `min_spend`, and `shipping_price` exactly as sent. A field that is missing or `null` is cleared. The coupon code and its usage state never change.

**folderId** `integer`

Folder ID. If not provided, coupons are created and overwritten in the default folder.

**codes** `array` *required*

Array of coupon code strings, up to 50,000 codes. Each code can have up to 255 characters.

**valid\_until** `string`

Expiration date in `YYYY-MM-DD` format.

**type** `string`

Discount type: `percentual` or `fixed`. Required when `value` is set.

**value** `number`

Discount value, greater than `0`. The maximum is `100` for `percentual` and `99999999.99` for `fixed`. Required when `type` is set.

**currency** `string`

Three-letter currency code, for example `CZK`. Required when `type` is `fixed` or when `min_spend` is set.

**min\_spend** `number`

Minimum order value, from `0` to `99999999.99`.

**shipping\_price** `string`

Shipping rule of the discount: `cart`, `free`, or `beforeDiscount`.

```bash cURL theme={null}
curl -X PUT https://api2.ecomailapp.cz/coupons/import \
  -H "key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "folderId": 1,
    "codes": ["code1", "code2", "code3", "code4"],
    "valid_until": "2025-12-31",
    "type": "fixed",
    "value": 200,
    "currency": "CZK",
    "min_spend": 1000,
    "shipping_price": "cart"
  }'
```

```php PHP theme={null}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api2.ecomailapp.cz/coupons/import');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'key: YOUR_API_KEY',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'folderId' => 1,
    'codes' => ['code1', 'code2', 'code3', 'code4'],
    'valid_until' => '2025-12-31',
    'type' => 'fixed',
    'value' => 200,
    'currency' => 'CZK',
    'min_spend' => 1000,
    'shipping_price' => 'cart',
]));
$response = curl_exec($ch);
curl_close($ch);
```

```json 200 theme={null}
{
  "imported": 1,
  "duplicated": 0,
  "updated": 3,
  "totalCount": 4
}
```

```json 422 theme={null}
{
  "errors": {
    "currency": ["The currency field is required when type is fixed."]
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.