Search Requests

Many times you will need to filter and sort your GETs. For example, you might want all the invoices belonging to a specific account ordered by date. To do this you need to use the search request header. Search requests allow you to filter and sort the returned data on one or more properties of the object. The basic forumula for the search request is:

  • A filter array that can be conceptualized as where clauses.
  • A condition which logically joins the filter array with the orderby array using a logical AND
  • An orderBy array that sorts the returned data

Filters

A filter combines a property, an operator, and a value. Since the filter is an array, elements can be combined using the condition property with a value of 'and'.

Filter Properties
name
"name": "accountID"
Type: String
The property you want to base the filter on. For a list of elgible filter properties you can use the associated Metadata API.
operator
"operator": "eq"
Type: String
The filter operator you want to use. Possible values include: eq, notEq, lt, ltEq, gt, gtEq, contains, etc.
value
"value": 42
Type: Number
The value or range of values to filter the property on. For a list, use comma separated values.
condition
"condition": "and"
Type: String
The condition property is used to chain together filters in the array.

Here is an example of a basic filter:

Combining Filters

Elements in the filters array are combined using the AND condition and by adding a new element to the array. Building on our previous example, here is an example of filter with two conditions:

Ordering Filters

The orderBy property allows you to sort the response items by ascending or descending values based on one of the properties. Let's add an orderby condition to our example:

Let's combine two orderBy elements and see what our filter looks like:

Making the Request

Let's add the header to our GET request. The resulting XHR code snippet: