Query object 'q'

The search query object, q, allows you to filter the results of certain GET endpoints based on specific parameters. For example, you can use the q query object to filter for contacts that have been updated in Front after a certain date, or to return a list of conversations that have an unassigned status. Using this query object allows you to return just the results you're looking for.

Syntax

The query object is passed as a query string parameter with the value q, the name of the parameter you are filtering for included in brackets, and the value of the parameter you are filtering for included after an equals sign. The query parameters available to filter on vary depending on the endpoint, but you can refer to the API reference documentation for the endpoint-specific parameters.

q[QUERY_PARAMETER]=QUERY_NAME

You can include multiple query objects within the same request.

q[QUERY_PARAMETER_A]=QUERY_NAME&q[QUERY_PARAMETER_B]=QUERY_NAME...

You can include multiple values for the same parameter.

q[QUERY_PARAMETER_A]=QUERY_NAME&q[QUERY_PARAMETER_A]=QUERY_NAME

Usage Examples

The following code block shows a request to the List events endpoint that includes query object filters to identify conversations that have been archived within a certain time period.

  • The query object is used to filter for events that occur between Saturday Apr 09 2022 and Sunday Apr 10 2022 using the [before] and [after] parameters with a Unix timestamp.
  • The query object is used to limit the results to conversation archive events using the [types] parameter with an archive value.
  • The names and values of these parameters are obtained from the List events API reference documentation. Refer to the Core API Reference documentation to obtain the query object parameters for other endpoints because these vary endpoint to endpoint.
https://api2.frontapp.com/events?q[types]=archive&q[before]=1649574000&q[after]=1649487600
curl 'https://api2.frontapp.com/events?q\[types\]=archive&q\[before\]=1649574000&q\[after\]=1649487600'

πŸ“˜

Make sure to format the brackets properly

Note that you should format the brackets properly depending on how you are making the request. For example, when using cURL, you escape the brackets (e.g. q\[before\]).

While it doesn't make sense to include multiple [before] or [after] parameters, you can include multiple [types] parameters to filter on more than one event type. For example:

https://api2.frontapp.com/events?q[types]=archive&q[types]=reopen&q[before]=1649574000&q[after]=1649487600
curl 'https://api2.frontapp.com/events?q\[types\]=archive&q\[types\]=reopen&q\[before\]=1649574000&q\[after\]=1649487600'

Sample endpoints that use the q search query object

The following endpoints support the q search query object. This list is meant as a quick jumping-off point for commonly filtered endpoints, but is not meant to be comprehensive. Refer to the Core API Reference documentation to learn if the query object is supported for a particular API endpoint.

Contacts

Conversations

Events

Links