Filtering the customer list

If you want to fetch a collection of customers.

GET: https://customers.prepr.io/customers

Filter customers by searching in name, company and email fields.

{
    "q" : [
        {
            "fz" : "Donald T"
        }   
    ]
}

Query by email

Find a customer by using an email address.

{
    "email_eq" : "mail@example.com"
}

Query by reference ID

Find a customer by using a Reference ID.

{
    "reference_id": [
        {
            "eq" : "323c93d0-dd2c-40d1-90fb-7454ea06761d" // Reference ID
        },
        {
            "in" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d", // Reference ID
            ]
        }
    ]
}

Query by events

Prepr customers can be filtered on the events they created.

In this example we show the liked filters. Next to liked filtering on viewed, voted, shared bookmarked, subscribed and signed_up is supported.

{
    "liked": [
        {
            "has" : true
        },
        {
            "hasn" : true
        },
        {
            "in" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d", // Content Item ID
            ]
        }
    ]
}

Query by segments

Prepr customers can be filtered on segments. You can query the segments field by using the segments as an argument.

Customers that are in the specified segment

This example requests all customers in the specified segment.

{
    "segments": [
        {
            "eq": "323c93d0-dd2c-40d1-90fb-7454ea06761d" // Segment Id
        }
    ]
}

Customers that are in on of the following segments

This example requests all customers in one of the specified segments. If a customer is in both segments it will be returned once.

{
    "segments": [
        {
            "in" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d",
                "8c4b2a7b-9827-4e57-8bd5-1ef04a046238"
            ]
        }
    ]
}

Query by tags

If you want to filter customers by related tags.

Customers that have a specified tag

{
    "tags": [
        {
            "eq": "323c93d0-dd2c-40d1-90fb-7454ea06761d" // Tag Id
        }
    ]
}

Customers that have one of the following tags

{
    "tags": [
        {
            "in" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d",
                "8c4b2a7b-9827-4e57-8bd5-1ef04a046238"
            ]
        }
    ]
}

Customers that have all of the following tags

{
    "tags": [
        {
            "all" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d",
                "8c4b2a7b-9827-4e57-8bd5-1ef04a046238"
            ]
        }
    ]
}

Customers that have none of the following tags

{
    "tags": [
        {
            "nin" : [
                "323c93d0-dd2c-40d1-90fb-7454ea06761d",
                "8c4b2a7b-9827-4e57-8bd5-1ef04a046238"
            ]
        }
    ]
}

Expanding fields

To request more customer data check out the Query by ID page.

Sorting customers

You can use the sort argument to order your query results in a particular order.

{
    "sort": "created_on"
}

It is possible to sort the customers by created, changed, published dates in either ascending or descending order.

The current values for sorting those fields are created_on, -created_on, changed_on, -changed_on, last_name, -last_name, first_name, -first_name, last_seen, -last_seen.

Pagination

Prepr returns collections of resources in a wrapper object that contains extra information useful for paginating overall results.

{
    "skip": 0,
    "limit": 2
}

Will result in:

{
    "items": [{...},{...}],
    "total": 98,
    "after": "YWZ0ZXJfMg==",
    "before": "YmVmb3JlXzA=",
    "skip": 0,
    "limit": 2
}

In the above example, a client retrieves the next 100 resources by repeating the same request, changing the skip query parameter to 100. You can use the sort parameter when paging through larger result sets to keep the order predictable. For example, sort=-created_on will order results by the time the resource was created.

Limit

You can specify the maximum number of resources returned as a limit query parameter.

Note: The maximum number of resources returned by the API is 1000. The API will throw a Bad Request for values higher than 1000 and values other than an integer.

The default number of resources returned by the API is 100.

Skip

You can specify an offset with the skip query parameter.

Note: The API will throw a Bad Request for values less than 0 or values other than an integer.

By combining skip and limit you can paginate through results:

Page 1: skip=0, limit=15 Page 2: skip=15, limit=15 Page 3: skip=30, limit=15 etc.