Skip to content
On this page

Create Discount ​

Create a new discount in your store.

Endpoint ​

POST /api/discount/create

Request Body ​

FieldTypeRequiredDescription
storeIdstringYesStore ID
codestringYesDiscount code
typestringYesfixed_amount, percentage, free_shipping
percentagenumberNoPercentage (if type=percentage)
valuenumberNoValue (if type=fixed_amount)
startDatedateNoStart date
endDatedateNoEnd date
productsarrayNoProduct objects
customersarrayNoCustomer IDs
requirementsobjectNoRequirements (price, quantity)
countriesarrayNoCountry IDs (for free shipping)
provincearrayNoProvince IDs
citiesarrayNoCity IDs
targetstringNoALL or SELECTED
activebooleanNoIs active
limitsobjectNoUsage limits
currenciesarrayNoCurrency-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",
    ...
  }
}

Released under the MIT License.