Vouchers

Vouchers are generated by the Rewards for a specific Customer account and they are applied during the purchasing process. They are defined by its value, validity and related Reward. Vouchers can be managed by this resource.

Available methods

All available methods for resource vouchers.

HTTP method Endpoint Description
[badge-blue GET] /vouchers Get a list of all vouchers
[badge-blue GET] /vouchers/{voucher_id} Get a specific voucher data

Actions

Action method for resource vouchers.

HTTP method Endpoint Description
[badge-green POST] /vouchers/{voucher_id}/actions/apply-voucher Application of a voucher


Get all vouchers

Get information as a list o all vouchers
[badge-blue GET] /vouchers

Query string

Parameter name Type Description Mandatory (Yes/No)
count integer The number of records to return.
Default value is 100.
No
offset integer The number of records from a collection to skip.
Default value is 0.
No
sort_field string One of the query string parameters for sorting.
Response is sorted by the specified field.
No
sort_direction string Direction of sorting the response list.
Possible values are: ASC / DESC
No
customer_id string The unique id for the customer that has the vouchers on the account No
code string Unique code of the voucher No
store_id string The unique id for the store where the reward was applied No
is_valid boolean Filter for valid vouchers
Possible values: true - all vouchers in validity range / false - all vouchers before or after validity range / no value - all vouchers
No
is_applied boolean Filter by voucher application and reservation
Possible values: true - all applied or reserved vouchers / false - all vouchers that have not been applied yet or that are not reserved actually / no value - all vouchers
No

Response

Status code: 200 OK
Output structure : object

Parameter name Type Description
vouchers Voucher[] List of all recent vouchers
total_items integer Count of all recent vouchers

Example Request

GET http://<projectURL>/rest-api/enterprise-interface/v1.0/vouchers?store_id=86e05affc7a7abefcd513ab400&customer_id=85bc5819e09db95437552ce79&is_valid=true&is_applied=true&count=1
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
Authorization: Basic ZW50ZXJwcmlzZV9pbnRlcmZhY2U6ZWZkGFmYjlmZDI1NzU2M2Q1ODNjMGQxMGMzYTIwZWMwZThiMWNlZGViYzJjNTBlOTNjZA==

Example response

HTTP/1.1 200 OK
Date: Fri, 11 Dec 2020 17:00:32 GMT
Content-Type: application/json; charset=utf-8

{
  "data": {
    "vouchers": [
      {
        "voucher_id": "8fbccbdba315e6240b07f239ba",
        "customer_id": "85bc5819e09dab95437552ce79",
        "store_id": "86e05affc7a7abefcd513ab400",
        "code": "",
        "value": 0,
        "applied_date": "2015-01-19 10:20:42",
        "valid_from": null,
        "valid_to": null,
        "reward_group": "83c0ee31e29036a1f436aef1ab",
        "reward": {
          "reward_id": "83c0ee31e29036a1f436aef1ab",
          "code": null,
          "name": "Happy hours",
          "note": "Happy hours prices",
          "subtitle": "null",
          "points_cost": 45,
          "valid_time_from": null,
          "valid_time_to": null,
          "reward_group": 0,
          "store_list": [],
          "additional_properties": [
            {
              "property_record_id": "percentage_discount:83c0ee31e29036a1f436aef1ab",
              "property_id": "percentage_discount",
              "property_name": "Percentage discount",
              "property_value": null,
              "last_change": null
            },
            {
              "property_record_id": "max_discount_value:83c0ee31e29036a1f436aef1ab",
              "property_id": "max_discount_value",
              "property_name": "Maximum discount value when percentage discount",
              "property_value": null,
              "last_change": null
            }
          ],
          "priority": null,
          "image_urls": [],
          "has_product_condition": false,
          "has_group_condition": false,
          "has_brand_condition": false,
          "is_automated": false,
          "last_change": "2016-01-11 11:50:50.106432",
          "state": 0
        },
        "last_change": "2015-01-19 10:20:42",
        "state": 1
      }
    ],
    "total_items": 3
  }
}


Get a voucher

Get information about a specific voucher
[badge-blue GET] /vouchers/{voucher_id}

Path parameters

Parameter name Type Description
voucher_id string The unique id for the voucher

Response

Status code: 200 OK
Output structure : Voucher

Example Request

GET http://<projectURL>/rest-api/enterprise-interface/v1.0/vouchers/8fbccbdba315e6240b07f239ba
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
Authorization: Basic ZW50ZXJwcmlzZV9pbnRlBmNTIzZjM4ZGFmYjDI1NzU2M2Q1ODNjMGQxMGMzYTIwZWMwZThiMWNlZGViYzJjNTBlOTNjZA==

Example response

HTTP/1.1 200 OK
Date: Fri, 11 Dec 2020 17:01:37 GMT
Content-Type: application/json; charset=utf-8

{
  "data": {
    "voucher_id": "8fbccbdba315e6240b07f239ba",
        "customer_id": "85bc5819e09dab95437552ce79",
        "store_id": "86e05affc7a7abefcd513ab400",
        "code": "",
        "value": 0,
        "applied_date": "2015-01-19 10:20:42",
        "valid_from": null,
        "valid_to": null,
        "reward_group": "83c0ee31e29036a1f436aef1ab",
        "reward": {
          "reward_id": "83c0ee31e29036a1f436aef1ab",
          "code": null,
          "name": "Happy hours",
          "note": "Happy hours prices",
          "subtitle": "null",
          "points_cost": 45,
          "valid_time_from": null,
          "valid_time_to": null,
          "reward_group": 0,
          "store_list": [],
          "additional_properties": [
            {
              "property_record_id": "percentage_discount:83c0ee31e29036a1f436aef1ab",
              "property_id": "percentage_discount",
              "property_name": "Percentage discount",
              "property_value": null,
              "last_change": null
            },
            {
              "property_record_id": "max_discount_value:83c0ee31e29036a1f436aef1ab",
              "property_id": "max_discount_value",
              "property_name": "Maximum discount value when percentage discount",
              "property_value": null,
              "last_change": null
            }
          ],
          "priority": null,
          "image_urls": [],
          "has_product_condition": false,
          "has_group_condition": false,
          "has_brand_condition": false,
          "is_automated": false,
          "last_change": "2016-01-11 11:50:50.106432",
          "state": 0
        },
        "last_change": "2015-01-19 10:20:42",
        "state": 1
      }
}


Application of a voucher

Sets a voucher as applied
[badge-green POST] /vouchers/{voucher_id}/actions/apply-voucher

Path parameters

Parameter name Type Description
voucher_id string The unique id for the voucher

Request

Parameter name Type Description Mandatory (Yes/No)
store_id string The unique id for the store where the voucher is applied No
date_applied string Date (ISO 8601) of voucher application
YYYY-MM-DD HH:MM:SS
Yes

Response

Status code: 204 No Content

Example Request

POST http://<projectURL>/rest-api/enterprise-interface/v1.0/vouchers/8dc30a90e28280d3ec5377f112/actions/apply-voucher
Content-Type: application/json
Accept-Language: cs, en-gb;q=0.8
Authorization: Basic ZW50ZXJwcmlzZV9pbnRlcmZhY2U6ZWZkYTIzZjM4ZGFmYjlmZDI1NzU2M2Q1ODNjMGQxMGMzYTIwZWMwZThiMWNlZGViYzJjNTBlOTNjZA==

{
  "date_applied" : "2020-12-10 10:00:00"
}

Example response

HTTP/1.1 204 No Content
Date: Fri, 11 Dec 2020 17:07:24 GMT
Content-Type: application/json; charset=utf-8