The contacts query supports an extensive selection of filters to help you identify high-value customers, find contacts due for re-engagement, generate compliance reports, export contact data to external platforms and more.
For example, you can identify contacts who are between 46 and 54 years old and live in Ontario, Canada.
query {
contacts(
filter: [
{
and: [
{
field: "Birthday"
between: {
from: "1971-01-01T00:00:00.000Z"
to: "1979-01-01T00:00:00.000Z"
}
}
{ field: "City", eq: "Ontario" }
]
}
]
) {
nodes {
attributes(selectByName: ["First name", "Email", "Birthday"]) {
name
value
}
}
totalCount
}
}
Complete reference
Each filter object in the contacts query can contain:
field(required): String - The name of the contact attribute to filter by. If you don't have the names of all available contact attributes, see Query the audience.
Text operators
blank: Boolean - Filter for empty/non-empty valuescontains: String - Filter for values containing this textcontainsOneOf: Array of strings - Filter for values containing any of these textsendsWith: String - Filter for values ending with this textendsWithOneOf: Array of strings - Filter for values ending with any of these textseq: String - Filter for exact matchesin: Array - Is in the list of valuesncontains: String - Filter for values not containing this textncontainsOneOf: Array of strings - Filter for values not containing any of these textsnendsWith: String - Filter for values not ending with this textnendsWithOneOf: Array of strings - Filter for values not ending with any of these textsneq: String - Filter for values not equal to this valuenin: Array - Is not in the list of valuesnstartsWith: String - Filter for values not starting with this textnstartsWithOneOf: Array of strings - Filter for values not starting with any of these textsstartsWith: String - Filter for values starting with this textstartsWithOneOf: Array of strings - Filter for values starting with any of these texts
Number operators
between: Object - Filter for values within a rangefrom(required): Number - Lower bound of the rangeto(required): Number - Upper bound of the range
blank: Boolean - Filter for empty/non-empty valueseq: Number - Filter for exact matchesgt: Number - Is greater thangte: Number - Is greater than or equal toin: Array - Is in the list of valueslt: Number - Is less thanlte: Number - Is less than or equal toneq: Number - Filter for values not equal to this valuenin: Array - Is not in the list of values
Date operators
after: String - Is after a given date (ISO 8601 format)anniversary: Object - Filter for anniversary exactly the provided number of days/weeks/months agoquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months.
before: String - Filter for dates before this value (ISO 8601 format)between: Object - Filter for values within a rangefrom(required): String - Lower bound of the rangeto(required): String - Upper bound of the range
blank: Boolean - Filter for empty/non-empty valuesday: Integer - Is in the given day (1-31)eq: Varies - Filter for exact matcheseqOneOf: Array of strings - Filter for values matching any of these optionsexactly: Object - Filter for dates exactly the provided number of days/weeks/months ago/awayquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
isAfterToday: Boolean - Filter for dates after todayisAnniversaryToday: Boolean - Filter for yearly anniversaries occurring todayisBeforeToday: Boolean - Filter for dates before todayisToday: Boolean - Filter for dates matching todayv+month: Integer - Is in the given month (1-12)neq: Varies - Filter for values not equal to this valueneqOneOf: Array of strings - Filter for values not matching any of these optionsnexactly: Object - Filter for dates not exactly the provided number of days/weeks/months agoquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months.
nwithinLast: Object - Filter for dates not within the provided number of last days/weeks/monthsquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
nwithinNext: Object - Filter for dates not within the provided number of next days/weeks/monthsquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
withinLast: Object - Filter for dates within the provided number of last days/weeks/monthsquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
withinLastRange: Object - Filter for dates within the provided range of last days/weeks/monthsfrom(required): Number - Starting quantityto(required): Number - Ending quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
withinNext: Object - Filter for dates within the provided number of next days/weeks/monthsquantity(required): Number - The numeric quantityperiod(required): Enum - The time period. Valid values:days,weeks,months
year: Integer - Is in the given year
Logical operators
and: Array of objects - Combine multiple conditions with AND logicnot: Object - Negate a conditionor: Array of objects - Combine multiple conditions with OR logic
Examples
Find corporate contacts using selected domains
filter: [
{
or: [
{ field: "Email", endsWith: "@company.com" }
{ field: "Email", endsWith: "@enterprise.com" }
{ field: "Email", endsWith: "@corp.net" }
]
}
]
Find contacts without email addresses
filter: [
{
field: "Email"
blank: true
}
]
Find contacts who were born in January
filter: [
{
field: "Birthday"
month: 1
}
]
