Order API - Create Voucher

Create voucher

Endpoint: POST *base*/voucher
Authentication: API Key

This will create a simple voucher of percentoff or priceoff type

Parameters

name
string
required

Name of the voucher.

code
string
optional

Code of the voucher. Will be generated a random one if not passed.

startDate
string
optional

Start date of the voucher in Y-m-d format. Will be set to current one if not passed.

stopDate
string
required

Stop date of the voucher in Y-m-d format.

type
enum
required

Type of the voucher. One of percentoff or priceoff

value
float
optional

Value of the voucher. Is required if percentoff is a voucher type

valueByPricelist
object
optional

Values by pricelist of the voucher, where price list ID is a key and discount is a value. Is required if priceoff is a voucher type.

store
int
required

Store id for voucher

markets
int|array
required

Markets for voucher

limit
int
optional

Limit of the voucher usage, where 0 means unlimited. Is 0 if not passes.

status
boolean
required

Is voucher active or inactive

conversionHtml
string
optional

Conversion html of the voucher

Request examples

POST <base>/voucher HTTP/1.1

{
    "name": "Welcome 10%",
    "stopDate": "2022-07-09",
    "type": "percentoff",
    "value": 10,
    "store": 1,
    "markets": 1,
    "status": true
}
POST <base>/voucher HTTP/1.1

{
   "name": "Welcome!",
   "stopDate": "2022-07-09",
   "type": "priceoff",
   "valueByPricelist": {
       "19": 100,
       "20": 10
   },
   "store": 1,
   "markets": 1,
   "status": true
}

Response

200 Content-type: application/json

status
string
required

ok if success, else no.

voucher
int
optional

ID of a created voucher

code
string
optional

Code of a created voucher

Response example

{
    "status": "ok",
    "voucher": 13,
    "code": "quooquadi_t6uqwecifin"
}

Errors example

Required fields are not passed

{
    "status": "no",
    "msg": {
        "name": "required",
        "stopDate": "required",
        "type": "required",
        "store": "required",
        "markets": "required",
        "status": "required"
    }
}

Market does not exist for a provided store

{
    "status": "no",
    "msg": {
        "markets": "Market 2 not found."
    }
}

Neither value nor valueByPricelist provided

{
    "status": "no",
    "msg": {
        "value": "One of 'value' or 'valueByPricelist' should be provided."
    }
}