Filtering and searching

Most list (or index) endpoints will allow you to filter or search using query parameters. Common use cases are:

  • Find a worker by their ID
  • Find a client by their full name
  • Only return visits that are scheduled to happen next week
  • Only return rates which are more than $50

Filters

Each filter is made up three parts:

  • Attribute: the available filterable query parameters that can be used for each resource
  • Operator: defaults to equals, but also supports other operators such as greater than etc.
  • Value: the static value you want to apply to the filter

Operators

OperatorDescriptionExample
eqEqual to (default)attribute=99
neNot equal toattribute[ne]=99
gtGreater thanattribute[gt]=99
gteGreater than or equal toattribute[gte]=99
ltLess thanattribute[lt]=99
lteLess than or equal toattribute[lte]=99

Filtering on null

By not providing a value to a filter, you can filter by null

OperatorDescriptionExample
eqEqual toattribute[eq]
neNot equal toattribute[ne]

Arrays

Some fields can accept multiple values (ie. those ending in [] and accepting an array parameter). In this case, multiple values can be provided as follows:

?ticket_template_ids[]=1&ticket_template_ids[]=2

Examples

We could apply the following filters to the visits endpoints:

FilterDescription
?client_id=99Return visits for the client with an ID of 99
?client_id=99&rating[lt]=5Return visits for the client with an ID of 99, that had a rating of less than 5
?actual_start_time[gte]=2023-01-01Return visits that started on, or after, January 1st, 2023
?actual_start_time[gte]=2023-01-01&actual_start_time[lte]=2023-01-07Return visits that started between January 1st-7th, inclusive
?worker_id[eq]Return visits where the worker_id is null

As an example of other field types, we could apply these filters to the workers endpoint:

FilterDescription
?archived=trueReturn archived workers
?archived=falseReturn active (non-archived) workers

Search

This can be done either by passing a value the q parameter and search against all specified attributes, or search against a specific attribute by specifying in the parameter.

Examples

We could search for clients by using the following parameters on the List all clients endpoint:

FilterDescription
?q=Name or [email protected]Return clients that match the search parameters
?q[full_name]=NameSearch clients by profile name
?q[email][email protected]Search clients by profile email address

The searchable attributes are specified in the parameters documentation for each endpoint.