Filters

The entity type of the filter determines which fields are available in conditions. The field type determines which operators are available. Here's a reference for the compatible fields and operators along with some usage examples.

Field reference

Party filters

Field Type
id Number
name String
jobTitle String
email String
phone String
city String
zip String
state String
country String
type String
tag Number, string
owner Number
team Number
hasEmailAddress Boolean
hasPhoneNumber Boolean
hasAddress Boolean
hasPeople Boolean
hasTags Boolean
addedOn Date
updatedOn Date
lastContactedOn Date
custom:{fieldId} Boolean, date, number, string
org.custom:{fieldId} Boolean, date, number, string
org.name String
org.tag Number, string

Opportunity filters

Field Type
id Number
name String
status String
milestone String
probability Number
lostReason String
currency String
expectedValue String
tag Number, string
owner Number
team Number
isOpen Boolean
isStale Boolean
isOwnedByMe Boolean
hasTags Boolean
addedOn Date
updatedOn Date
closedOn Date
expectedCloseOn Date
custom:{fieldId} Boolean, date, number, string

Case filters

Field Type
id Number
name String
status String
tag Number, string
owner Number
team Number
isOpen Boolean
isOwnedByMe Boolean
hasTags Boolean
addedOn Date
updatedOn Date
closedOn Date
expectedCloseOn Date
custom:{fieldId} Boolean, date, number, string

Operator reference

Operator Supported Field Types Type of Value
is Boolean, date, number, string As field type
is not Boolean, date, number, string As field type
starts with String String
ends with String String
contains String String
is greater than Number Number
is less than Number Number
is after Date Date
is before Date Date
is older than Date Number (of days)
is within last Date Number (of days)
is within next Date Number (of days)

Usage examples

Basic example

To find all parties tagged with example:

POST
https://api.capsulecrm.com/api/v2/parties/filters/results
{
  "filter": {
    "conditions": [
      {
        "field": "tag",
        "operator": "is",
        "value": "example"
      }
    ]
  }
}

Querying by ID

Tags can also be referenced by ID. This is useful because it ensures that conditions will continue to work even if the tag is renamed:

POST
https://api.capsulecrm.com/api/v2/parties/filters/results
{
  "filter": {
    "conditions": [
      {
        "field": "tag",
        "operator": "is",
        "value": 123
      }
    ]
  }
}

Multiple search conditions

To find all people in the United States that were added in 2018:

POST
https://api.capsulecrm.com/api/v2/parties/filters/results
{
  "filter": {
    "conditions": [
      {
        "field": "type",
        "operator": "is",
        "value": "person"
      },
      {
        "field": "country",
        "operator": "is",
        "value": "US"
      },
      {
        "field": "addedOn",
        "operator": "is after",
        "value": "2017-12-31"
      },
      {
        "field": "addedOn",
        "operator": "is before",
        "value": "2019-01-01"
      }
    ]
  }
}

Using a nested condition group

To find opportunities owned by user 123 or user 456:

POST
https://api.capsulecrm.com/api/v2/opportunities/filters/results
{
  "filter": {
    "conditions": [
      {
        "orGroup": [
          {
            "field": "owner",
            "operator": "is",
            "value": 123
          },
          {
            "field": "owner",
            "operator": "is",
            "value": 456
          }
        ]
      }
    ]
  }
}

Specifying results order

To find all people sorted by last contact date:

POST
https://api.capsulecrm.com/api/v2/parties/filters/results
{
  "filter": {
    "conditions": [
      {
        "field": "type",
        "operator": "is",
        "value": "person"
      }
    ],
    "orderBy": [
      {
        "field": "lastContactedOn",
        "direction": "ascending"
      }
    ]
  }
}

Filtering by custom field value

When filtering by custom field, it should be referenced by its ID. To find all parties with a value of true in a custom field with an ID of 1:

POST
https://api.capsulecrm.com/api/v2/parties/filters/results
{
  "filter": {
    "conditions": [
      {
        "field": "custom:1",
        "operator": "is",
        "value": true
      }
    ]
  }
}