Filtering and Sorting on List Actions

Limited Filtering Coverage

Please note that only a subset of the available List Actions in the Procore Connect API currently support filtering. Please see the individual endpoint documentation pages for filtering capability. Filtering coverage will be expanded in future releases of the API.

Introduction

The Procore Connect API supports filtering on List Actions to make large response data sets easier to work with. You can filter on supported attributes included in the response and you can filter on more than one attribute at a time.

Filtering Syntax

Filtering is simple to implement by appending the names of the attributes and the values you want to filter on to the List Action endpoint. Filters are implemented as query parameters on top of the base URL. The most common syntax for adding filters to a List Action is:

&filters[<ATTRIBUTE_NAME>]=<VALUE_TO_FILTER_ON>

You can string together multiple filters on a single List Action call as a logical AND to further refine your results:

&filters[<ATTRIBUTE_NAME>]=<VALUE_TO_FILTER_ON>&filters[<ATTRIBUTE_NAME>]=<VALUE_TO_FILTER_ON>...

Examples

Here are a few examples to get you started using the filtering capabilities in Procore Connect API.

First, let's look at a simple case of filtering a list of Work Order Contracts (subcontract) on the Status field. We only want to return the items with a Status of 'Approved' so we'll format our call as follows:

GET https://api-sandbox.procore.com/vapid/work_order_contracts?project_id=225096&filters[status]=Approved

Now, let's look at an example that returns multiple records. This time we'll string filters together to return two Work Order Contracts with two specific ID's.

GET https://api-sandbox.procore.com/vapid/work_order_contracts/?project_id=225096&filters[id]=779632&filters[id]=786001

Finally, let's take a look at filtering a response based on a date range. Here we use the created_at parameter with the List Purchase Order Contracts action to return a list of purchase orders that were created on September 23, 2016 between 16:30 and 17:00 UTC.

GET https://api-sandbox.procore.com/vapid/purchase_order_contracts/?project_id=225096&filters[created_at]=\"2016-09-23T16:30:00Z...2016-09-23T17:00:00Z\"

It is important to note that the date-time string used with the created_at and updated_at parameters must adhere to ISO8601 standards. In addition, these parameters must be formatted as a range using the ... delimiter.

Filtering on User-Defined Field Values

There are a number of resources in the Procore Connect API (such as RFIs) that provide List Action filtering on fields that have user-defined values. For example, the List RFIs endpoint allows you to filter the response by responsible contractor ID using filters[responsible_contractor_id] as a query parameter. However, you must first use a helper method that returns the available values for the responsible_contractor_id field as illustrated below.

Filter options helper method...

GET https://app.procore.com/vapid/projects/123456/rfis/filter_options/responsible_contractor_id

Example JSON response...

[
  {
    "key": 3968037,
    "value": "Joey's Civil Engineering"
  },
  {
    "key": 3968067,
    "value": "My Sub Company"
  }
]

From the response you can determine the ID (key) for the value that you want to filter on, and use that when you call the List RFIs endpoint as shown here...

GET https://app.procore.com/vapid/projects/123456/rfis?filters[responsible_contractor_id]=3968037

Date Range Filtering on Daily Logs

Many of the Daily Log List Action endpoints (e.g., List Accident Logs, List Delivery Logs, etc.) support filtering on dates and date ranges. However, the syntax for Daily Log filtering differs somewhat from that described above. Use the following syntax for adding date range filtering to Daily Logs.

To filter on a specific date, use the log_date query parameter with the following syntax...

?log_Date=<yyyy-mm-dd>

For example...

GET https://app.procore.com/vapid/projects/123456/accident_logs?log_date=2017-02-09

To filter on a date range, use the start_date and end_date query parameters with the following syntax...

?start_date=<yyyy-mm-dd>&end_date=<yyyy-mm-dd>

For example...

https://app.procore.com/vapid/projects/123456/accident_logs?start_date=2017-02-08&end_date=2017-02-09

Note that calling the List Action with no date query parameters only returns records for the current (today's) date.

See Working with Daily Logs for additional information.

Sorting on List Actions

In addition to filtering the results of List Actions, you can also sort the results based on specified fields. Add sorting to your API call by adding the sort query parameter with the following syntax:

/vapid/<procore_endpoint>?sort=<field_name>

For example, here is a call to the List Observations endpoint with sorting by the status field:

https://app.procore.com/vapid/observations/items?project_id=123456&sort=status

Note that you can also multi-sort by passing in comma-separated field attributes, in the order of importance:

/vapid/<procore_endpoint>?sort=<field_name1>,<field_name2>,<field_name3>

By default, sorting occurs in ascending order. You can use sort=- to sort results in descending order.

Limited Sorting Coverage

Please note that only a subset of the available List Actions in the Procore Connect API currently support sorting.