Filters

Some API calls allow you to pass filters that limit the output in the response or modify the behavior of the API call. Some filters are specified as query parameters in the URL and others are specified in the request body.

State filters

State filters are used to retrieve only the data that meets certain criteria. They are typically used to filter by the state of an object, such as active, inactive, or other states. These are generally passed as query parameters.

Date filters

Date filters are used to retrieve only the data that meets certain criteria based on the date. They are typically used to filter by the date of an object, such as created_at, updated_at, or other dates. In some cases, these are passed as query parameters (such as when using the 'after' filter), but at other times these are passed as request body parameters (such as for the sales-data endpoint).

Revenue Classifications

Revenue Classifications are used to limit the experiences that are returned in a /redeem/check response or to limit the experiences considered for redemption in a /redeem-unified call. The values for these classifications can be found below:

"accommodation" (Accommodation)
"food_and_beverage" (Food & Beverage)
"events" (Events)
"spa" (Spa)
"sundry" (Sundry)

Meta condition filters

Meta Condition filters which are a new addition to the API that allows for a high degree of flexibility with some objects. Meta can be added to some objects within the dashboard which allows for complex filtering within the API.

Available Operators

You can currently filter in the following ways:


equals: Checks the value of a singular key on the voucher and compares it with a singular value that you provide. 
contains: Checks an array of values assigned to the key passed in against your singular value.
in: Checks a singular value of the key provided, passing if the value of that key exists in the array you provide

The below snippet shows an example of filters being used with the Unified Redemptions API endpoint to illustrate the types of comparison. Please note that these should be used sparingly for the best effect.


{
    "voucher_no": "XXXXXXXXXX",
    "site_id": "X",
    "max_value": 250,
    "filters": {
        "meta_conditions": [
            {
                "key": "rate_plan",
                "operator": "equals",
                "value": "My Hotel Stay"
            },
            {
                "key": "room_type",
                "operator": "contains",
                "value": "double"
            },
            {
                "key": "area",
                "operator": "in",
                "value": [
                    "restaurant",
                    "bar"
                ]
            }
        ]
    }
}