Create Discount
Create a new discount in your store.
Endpoint
POST /api/discount/createRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
| storeId | string | Yes | Store ID |
| code | string | Yes | Discount code |
| type | string | Yes | fixed_amount, percentage, free_shipping |
| percentage | number | No | Percentage (if type=percentage) |
| value | number | No | Value (if type=fixed_amount) |
| startDate | date | No | Start date |
| endDate | date | No | End date |
| products | array | No | Product objects |
| customers | array | No | Customer IDs |
| requirements | object | No | Requirements (price, quantity) |
| countries | array | No | Country IDs (for free shipping) |
| province | array | No | Province IDs |
| cities | array | No | City IDs |
| target | string | No | ALL or SELECTED |
| active | boolean | No | Is active |
| limits | object | No | Usage limits |
| currencies | array | No | Currency-specific values |
Example
json
{
"storeId": "store_id",
"code": "SUMMER2024",
"type": "percentage",
"percentage": 15,
"startDate": "2024-06-01T00:00:00.000Z",
"endDate": "2024-06-30T23:59:59.000Z",
"products": [
{ "_id": "product_id", "by_quantity": false, "quantity": 0 }
],
"customers": ["customer_id"],
"requirements": { "price": 100, "quantity": 0 },
"countries": ["country_id"],
"province": ["province_id"],
"cities": ["city_id"],
"target": "ALL",
"active": true,
"limits": { "per_customer": 1, "all": 100 },
"currencies": [
{
"currency": "USD",
"properties": [
{ "name": "value", "value": 10 }
]
}
]
}Response
json
{
"status": "success",
"data": {
"_id": "string",
"code": "SUMMER2024",
...
}
}