Create voucher

Order API v1
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 example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
POST <base>/voucher HTTP/1.1

{
   "name": "Welcome 10%",
   "stopDate": "2020-07-09",
   "type": "percentoff",
   "value": 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

1
2
3
4
5
{
    "status": "ok",
    "voucher": 13,
    "code": "quooquadi_t6uqwecifin"
}

Errors example

Required fields are not passed

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "status": "no",
    "msg": {
        "name": "required",
        "stopDate": "required",
        "type": "required",
        "store": "required",
        "markets": "required",
        "status": "required"
    }
}

Market does not exist for a provided store

1
2
3
4
5
6
{
    "status": "no",
    "msg": {
        "markets": "Market 2 not found."
    }
}

Neither value nor valueByPricelist provided

1
2
3
4
5
6
{
    "status": "no",
    "msg": {
        "value": "One of 'value' or 'valueByPricelist' should be provided."
    }
}