You can filter the results of any query by using the filter argument. This makes it easy to retrieve specific information, like any threads assigned to a particular user, but much more complex queries are also possible.

For example, to return all open threads that are assigned to a particular user, you can use the following query:

query {
  threads(filters: [
    {
      "field": "status",
      "operation": "IN",
      "value": ["New", "Open", "Escalated", "Waiting for Customer"]
    },
    {
      "field": "ownerId",
      "operation": "EQUALS",
      "value": "1"
    }
  ]) {
    id
    body
    status
    owner {
      id
      name
    }
  }
}

Operations

You can use the following operations to filter your results:

OperationDescriptionType
BETWEENBetween two given values.[string, string]
INOne of the given values.string[]
NOT_INNot one of the given values.string[]
EQUALSEqual to given value.[string]
NOT_EQUALSNot equal to given value.[string]
GREATERGreater than given value.[string]
LESSLess than given value.[string]
GREATER_EQUALSGreater than or equal to given value.[string]
LESS_EQUALSLess than or equal to given value.[string]
LIKELike given value. (Accepts the % operator)[string]
NOT_LIKENot like given value. (Accepts the % operator)[string]
ILIKELike given value, ignoring case. (Accepts the % operator)[string]
NOT_ILIKENot like given value, ignoring case. (Accepts the % operator)[string]
CONTAINSContains given value.[string]
NOT_CONTAINSNot contains given value.[string]
ICONTAINSContains given value, ignoring case.[string]
NOT_ICONTAINSNot contains given value, ignoring case.[string]
STARTS_WITHStarts with given value.[string]
DOES_NOT_START_WITHNot starts with given value.[string]
ARRAY_CONTAINSArray contains given value.[string]
NULLThe value of the field must be null.[]
NOT_NULLThe value of the field must not be null.[]
ARRAY_EMPTYArray is empty.[]
ARRAY_NOT_EMPTYArray is not empty.[]

Logical operators

By defailt, all fields described in the filter need to be matched. The filter merges all conditions together using a logical and operator.

For example, the below example will find all threads that were created before a specific timeframe and are assigned to a particular user.

query {
  threads(filters: [
    {
      "field": "createdAt",
      "operation": "LESS",
      "value": "2024-05-31T16:34:11.909Z" # ISO 8601 Format
    },
    {
      "field": "ownerId",
      "operation": "EQUALS",
      "value": "1"
    }
  ]) {
    id
    body
    createdAt
    owner {
      id
      name
    }
  }
}

To change the logical operator, all filters support the or keyword that lets you switch to a logical or operator. For example, to find all threads that were created before a specific timeframe or are assigned to a particular user, you can use the following query:

query {
  threads(filters: [
    {
      "field": "createdAt",
      "operation": "LESS",
      "value": "2024-05-31T16:34:11.909Z" # ISO 8601 Format
      "or": [
        {
          "field": "ownerId",
          "operation": "EQUALS",
          "value": "1"
        }
      ]
    }
  ]) {
    id
    body
    createdAt
    owner {
      id
      name
    }
  }
}

Filtering by relationship

Data can also be filtered based on their relations, For example, you can filter threads based on the properties of their owner. To query all threads assigned to a particular email address, you can use the following query:

query {
  threads(filters: [
    {
      "field": "owner.email",
      "operation": "EQUALS",
      "value": "john@withchanneled.com"
    }
  ]) {
    id
    body
    owner {
      id
      name
      email
    }
  }
}