Vouchers
This is used to view, create, update and delete vouchers.
Voucher Properties
| id |
{ "id" : 255 }
The unique ID of the voucher |
| code |
{ "code" : "TENOFF" }
The text/number string entered by the customer to get the discount |
| discount |
{ "discount" : {
"type": "percent",
"value": 75.75
}
}
The discount object |
| validFrom |
{ "validFrom" : "Wed, 30 Sep 2015 20:15:00 +0000" }
The time & date the voucher can be used from, must use the exact format in the example DAY, DD MMM YYYY HH:MM:SS +0000 |
| expiresOn |
{ "expiresOn" : "Thu, 01 Oct 2015 17:15:00 +0000" }
The time & date the voucher cannot be used beyond, must use the exact format in the example DAY, DD MMM YYYY HH:MM:SS +0000 |
| target |
{ "target" : {
"type": "orders_over",
"value": 50
}
}
The target object |
| active |
{ "active" : true }
Either true or false |
| uses |
{ "uses" : 10 }
The maximum number of times the voucher can be used |
| used |
{ "used" : 4 }
The number of times the voucher has been used |
| customerUses |
{ "customerUses" : 2 }
The maximum number of times an individual customer account can use the voucher |
| comments |
{ "comments" : "Adwords campaign IDD1 voucher" }
Any internal comments for the voucher |
Voucher Discount Properties
| type |
{ "type" : "percent" }
Either percent (for percentage discounts), amount (for fixed value discounts) or free_shipping |
| value |
{ "value" : 10.00 }
Only set for percent or amount vouchers |
Voucher Target Properties
| type |
{ "type" : orders_over }
Either orders_over (applicable to orders over X), category (for orders on products in a particular leaf category) or product (for orders on particular products) |
| value |
{ "value" : 10.00 }
Only set for orders_over |
| ids |
{ "ids" : [12, 24] }
Only set for category or product, the unique IDs for the categories or products |
What you can do with Vouchers
GET /v1/vouchers
Receive a list of all vouchers
GET /v1/vouchers/count
Count the number of vouchers
GET /v1/vouchers/ID
Receive a single voucher
POST /v1/vouchers
Create a new voucher
PUT /v1/vouchers/ID
Update a voucher
DELETE /v1/vouchers/ID
Delete a voucher
GET /v1/vouchers
Returns all vouchers. By default the first 50 regular vouchers are returned, sorted by creation date.
| fields | Comma separated list of properties to include |
| sort | code or code_desc (default is creation date) |
| count | Count |
| offset | Offset |
| code | Specify the voucher's code, e.g. 10POUND to return all vouchers with that code |
GET /v1/vouchers
HTTP/1.1 200 OK
[
{
"id": 1,
"code": "V10",
"discount": {
"type": "percent",
"value": 10
},
"active": true
}
]
GET /v1/vouchers/count
Returns a count of the vouchers.
GET /v1/vouchers/count
HTTP/1.1 200 OK
{
"count": 99
}
GET /v1/vouchers/ID
Returns a single voucher.
| fields | Comma separated list of properties to include |
GET /v1/vouchers/14
HTTP/1.1 200 OK
{
"id": 14,
"code": "API",
"discount": {
"type": "percent",
"value": 75.75
},
"validFrom": "Wed, 30 Sep 2015 20:15:00 +0000",
"expiresOn": "Thu, 01 Oct 2015 17:15:00 +0000",
"target": {
"type": "orders_over",
"value": 50
},
"active": true,
"uses": 99,
"customerUses": 9,
"comments": "Comments"
}
POST /v1/vouchers
Creates a new voucher.
POST /v1/vouchers
POST /v1/vouchers
{
"code": "TWENTYOFF",
"discount": {
"type": "percent",
"value": 20
},
"active": true,
"uses": 100
}
POST /v1/vouchers
HTTP/1.1 201 Created
{
"id": 15,
"code": "TWENTYOFF",
"discount": {
"type": "percent",
"value": 20
},
"active": true,
"uses": 100
}
PUT /v1/vouchers/ID
Update a voucher. All object properties are allowed.
PUT /v1/vouchers/14
PUT /v1/vouchers/14
{
"code": "THIRTYOFF",
"discount": {
"type": "amount",
"value": 30
},
"active": false
}
PUT /v1/vouchers/14
HTTP/1.1 200 OK
{
"id": 15,
"code": "THIRTYOFF",
"discount": {
"type": "amount",
"value": 30
},
"active": false,
"uses": 100
}
DELETE /v1/vouchers/ID
Deletes an existing voucher.
Returns 204 No Content on success.