Skip to Content
Mutation APIFiltering customers

Filtering the customer list

Use this endpoint to fetch a collection of customers.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json

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

The example below searches customers for the text Donald T.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "q": [ { "fz": "Donald T" } ] }

Query by email

Find a customer by using an email address.

The example below fetches customers with the email address [email protected].

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "email_eq": "[email protected]" }

Query by reference ID

Find a customer by using a Reference ID.

The example below fetches customers with the reference ID 323c93d0-dd2c-40d1-90fb-7454ea06761d.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "reference_id_eq": "323c93d0-dd2c-40d1-90fb-7454ea06761d" }

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

The example below fetches customers in the specified segment.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "segments": [ { "eq": "323c93d0-dd2c-40d1-90fb-7454ea06761d" } ] }

Customers that are in one of the following segments

The example below fetches customers in one of the specified segments. If a customer is in both segments, it is returned once.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "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

The example below fetches customers with the specified tag.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "eq": "323c93d0-dd2c-40d1-90fb-7454ea06761d" } ] }

Customers that have one of the following tags

The example below fetches customers with one of the specified tags.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "in": [ "323c93d0-dd2c-40d1-90fb-7454ea06761d", "8c4b2a7b-9827-4e57-8bd5-1ef04a046238" ] } ] }

Customers that have all of the following tags

The example below fetches customers with all of the specified tags.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "all": [ "323c93d0-dd2c-40d1-90fb-7454ea06761d", "8c4b2a7b-9827-4e57-8bd5-1ef04a046238" ] } ] }

Customers that have none of the following tags

The example below fetches customers with none of the specified tags.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "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.

The example below sorts customers by the created_on field in ascending order.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "sort": "created_on" }

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

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

Pagination

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

The example below fetches customers with skip set to 0 and limit set to 2.

GET https://customers.prepr.io/ Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "skip": 0, "limit": 2 }

Will result in:

{ "items": [{...},{...}], "total": 98, "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.

Last updated on