Sort and Filter

Several of the Files.com API resources have list operations that return multiple instances of the resource. The List operations can be sorted and filtered.

Sorting

To sort the returned data, use the sort_by query parameter.

Sort Syntax

sort_by[<field>]=<value>
ComponentDescription
<field>The name of the field to sort by, placed within square brackets []. Each resource supports a unique set of valid sort fields and can only be sorted by one field at a time.
<value>The sort order: asc (ascending) or desc (descending).

Special note about the List Folder Endpoint

For historical reasons, and to maintain compatibility with a variety of other cloud-based MFT and EFSS services, Folders will always be listed before Files when listing a Folder. This applies regardless of the sorting parameters you provide. These will be used, after the initial sort application of Folders before Files.

Sort Example

# users sorted by username
curl https://app.files.com/api/rest/v1/users.json?sort_by[username]=asc \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Filtering

Filters apply selection criteria to the underlying query that returns the results. They can be applied individually or combined with other filters, and the resulting data can be sorted by a single field.

Each resource supports a unique set of valid filter fields, filter combinations, and combinations of filters and sort fields.

Filter Syntax

<filter>[<field>]=<value>
ComponentDescription
<filter>The filter to use.
<field>The name of the field to filter by, placed within square brackets []. Each resource supports a unique set of valid filter fields.
<value>The field value that the filter should apply to.

Filter Types

FilterTypeDescription
filterExactFind resources that have an exact field value match to a passed in value. (i.e., FIELD_VALUE = PASS_IN_VALUE).
filter_prefixPatternFind resources where the specified field is prefixed by the supplied value. This is applicable to values that are strings.
filter_gtRangeFind resources that have a field value that is greater than the passed in value. (i.e., FIELD_VALUE > PASS_IN_VALUE).
filter_gteqRangeFind resources that have a field value that is greater than or equal to the passed in value. (i.e., FIELD_VALUE >= PASS_IN_VALUE).
filter_ltRangeFind resources that have a field value that is less than the passed in value. (i.e., FIELD_VALUE < PASS_IN_VALUE).
filter_lteqRangeFind resources that have a field value that is less than or equal to the passed in value. (i.e., FIELD_VALUE <= PASS_IN_VALUE).

Exact Filter Example

# non admin users
curl https://app.files.com/api/rest/v1/users.json?filter[not_site_admin]=true \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Range Filter Example

# users who haven't logged in since 2024-01-01
curl https://app.files.com/api/rest/v1/users.json?filter_gteq[last_login_at]=2024-01-01 \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Pattern Filter Example

# users whose usernames start with 'test'
curl https://app.files.com/api/rest/v1/users.json?filter_prefix[username]=test \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'

Combination Filter with Sort Example

# users whose usernames start with 'test' and are not admins, sorted by username
curl https://app.files.com/api/rest/v1/users.json?filter_prefix[username]=test&filter[not_site_admin]=true&sort_by[username]=asc \
  -H 'X-FilesAPI-Key: YOUR_API_KEY'