Concept
Filters
Filters describe the records you want: by demographic attribute, address, vehicle, business identifier, anything exposed by the data source. They are the same shape on every endpoint that takes one.
Shape of a filter
A filter is a JSON object with a required field and values array, plus optional condition, option, and omit attributes. Endpoints accept a list of filters and combine them with AND by default.
The field name is the key attribute exposed by GET /api/v1/data_sources/:id. Available keys differ by data source. Fetch the data source first if you're unsure what's filterable.
{
"filters": [
{ "field": "state", "values": ["TX", "OK"] }
]
}
Match options
The option attribute controls how each value is compared. Most string fields accept either exact or partial matching; numeric and enum fields ignore option.
{
"filters": [
{ "field": "title", "values": ["director"], "option": "like" }
]
}
Negating with omit
Set omit: true to exclude records matching the filter instead of including them. Negation runs against the field independently. Combine multiple negations to peel unwanted records off a broad base.
{
"filters": [
{ "field": "state", "values": ["TX"] },
{ "field": "county", "values": ["Dallas"], "omit": true }
]
}
ZIP radius fields (zip_radius, zip4_radius and their secondary_ versions) honor omit and exclude the records inside the radius. They used to ignore it and include those records. One whose values all match nothing excludes nothing. coordinate_radius, rooftop_radius, polygon and map_area still ignore omit and always include the records inside the shape.
Range fields
Some numeric or bucketed fields (age, income, year built) accept inclusive ranges as hyphenated strings. Pass several ranges in the same values array to combine them.
{
"filters": [
{ "field": "est_age", "values": ["18-21", "25-30"] }
]
}
Date range fields (birth date, purchase date, move date and the like) take two values, from and to, each YYYY-MM-DD. Send "" for an open side. A single string holding both ISO dates is split into the two values; any other shape is rejected with a 422.
{
"filters": [
{ "field": "birth_date_range", "values": ["1962-03-01", "1962-08-31"] }
]
}
AND and named OR groups
By default every filter in the array is AND'd together. To express OR, give two or more filters the same condition string. They become a named group where a record only needs to match one filter in the group. The top-level array remains AND, so groups slot into the larger AND expression as a single OR'd term.
{
"filters": [
{ "field": "active_investor", "values": ["Y"] },
{ "field": "state", "values": ["NY"], "condition": "group1" },
{ "field": "zip", "values": ["91361"], "condition": "group1" }
]
}
You can stack multiple named groups (group1, group2, …). Each one is an independent OR, and all of them are AND'd with the rest of the array.
Segments within an audience
Named OR groups combine filters inside a segment. An audience can contain several segments, each combined with the ones before it using AND, OR, or AND NOT. Assign a filter to a segment with segment_id, and set each segment's joiner. The first segment has nothing before it, so it must not have one.
{
"segment_match_type": "address_zip",
"segments": [
{ "id": "1", "name": "Investors in NY" },
{ "id": "2", "name": "Exclude 91361", "joiner": "AND NOT" }
],
"filters": [
{ "field": "active_investor", "values": ["Y"], "segment_id": "1" },
{ "field": "state", "values": ["NY"], "segment_id": "1" },
{ "field": "zip", "values": ["91361"], "segment_id": "2" }
]
}
segment_match_type makes a joiner meaningful by naming the key used to match records across segments. Without it there is nothing to intersect or subtract on, so joiners are ignored, segments are unioned, and a record that matches two segments is counted in both.
A filter with no segment_id applies to every segment. When you send more than one segment, each segment receives its own copy of an unassigned filter, so filters read back from the API have explicit ownership.
Segments belong to the audience that owns them. An audience built from segments cannot also join a classic audience group, which is a separate feature for combining whole audiences.
Counting a segmented audience
The count endpoints take filters, not segments. /data/count, /data/query, /count_requests, and /lists evaluate the filter array as one expression, so sending a segmented audience's filters to any of them returns a different number than the audience itself reports. Read the audience to get its count.
Used by