Webhook Filters

Use JSON event filters to apply advanced filtering logic to webhook subscriptions.
View as Markdown

More advanced event filtering can be achieved by specifying event filters when creating/modifying a webhook subscription. For a webhook to be fired the event must match these extra filters as well as the specified object_type and action values.

Event filters use JSON to specify filtering conditions on event fields. The following filter operators can be combined to apply sophisticated filtering logic.

  • Equals: {"type": "equals", "value": "<value>"} This filter matches only if the entire value is the same as provided.
  • Not Equals: {"type": "not_equals", "value": "<value>"} This filter matches only if the value does not match what is provided.
  • Is Null: {"type": "is_null"} This filter matches only if the value of the specified field is null.
  • Non Null: {"type": "non_null"} This filter matches only if the value of the specified field is non-null.
  • Contains: {"type": "contains", "value": "<value>"} This searches for a particular value in an array. It can also be used to match a partial string for string fields.
  • And: {"type": "and", "filters": [<filter1>, <filter2>, ...]} This matches when all provided individual filters match.
  • Or: {"type": "or", "filters": [<filter1>, <filter2>, ...]} This matches when one or more provided individual filters match.
  • Not: {"type": "not", "filter": <some other filter>} This matches when the provided filter does not match.

The matching operators above can be applied to individual parts of the event using these two methods of accessing field values:

  • Field Accessor: {"type": "field_accessor", "field": "<field name>", "filter": <some other filter>} This filter allows you to access a specific field in a JSON document and match this field’s value against the specified filter.
  • Any value in an array: {"type": "any_array_value", "filter": <some other filter>} This searches for any matching values inside a JSON list/array.

Examples

user_id string field of an event equals user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA

1{
2 "type": "field_accessor",
3 "field": "user_id",
4 "filter": {
5 "type": "equals",
6 "value": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
7 }
8}

Drill into event to match user_id of the data object to match events created by user user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA

1{
2 "type": "field_accessor",
3 "field": "data",
4 "filter": {
5 "type": "field_accessor",
6 "field": "user_id",
7 "filter": {
8 "type": "equals",
9 "value": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
10 }
11 }
12}

Match events not created by user user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA

1{
2 "type": "field_accessor",
3 "field": "data",
4 "filter": {
5 "type": "field_accessor",
6 "field": "user_id",
7 "filter": {
8 "type": "not",
9 "filter": {
10 "type": "equals",
11 "value": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
12 }
13 }
14 }
15}

You can also use not_equals as a filter type in this case:

1{
2 "type": "field_accessor",
3 "field": "data",
4 "filter": {
5 "type": "field_accessor",
6 "field": "user_id",
7 "filter": {
8 "type": "not_equals",
9 "value": "user_N6KhMpzHRCYQHdn4gRNIFNN5JExnsrprKA6ekxM63XA"
10 }
11 }
12}

Match events where the user_id field is non-null

1{
2 "type": "field_accessor",
3 "field": "user_id",
4 "filter": {
5 "type": "non_null"
6 }
7}

Match events for leads with string travel in the name (e.g. ‘Bluth travel company’, case sensitive)

1{
2 "type": "field_accessor",
3 "field": "data",
4 "filter": {
5 "type": "field_accessor",
6 "field": "name",
7 "filter": {
8 "type": "contains",
9 "value": "travel"
10 }
11 }
12}

Match events for leads that had their name changed. This uses a contains filter because changed_fields is an array of field names.

1{
2 "type": "field_accessor",
3 "field": "changed_fields",
4 "filter": {
5 "type": "contains",
6 "value": "name"
7 }
8}

Match events for leads that had their name or description changed

1{
2 "type": "field_accessor",
3 "field": "changed_fields",
4 "filter": {
5 "type": "or",
6 "filters": [
7 {
8 "type": "contains",
9 "value": "name"
10 },
11 {
12 "type": "contains",
13 "value": "description"
14 }
15 ]
16 }
17}

Match events that have two custom fields set to specific values

1{
2 "type": "and",
3 "filters": [
4 {
5 "type": "field_accessor",
6 "field": "data",
7 "filter": {
8 "type": "field_accessor",
9 "field": "custom.cf_rR9HjgjI4SYy1X1IlMOozK2VkxMgU5NnHquTR8DVxoQ",
10 "filter": {
11 "type": "equals",
12 "value": "product_1234"
13 }
14 }
15 },
16 {
17 "type": "field_accessor",
18 "field": "data",
19 "filter": {
20 "type": "field_accessor",
21 "field": "custom.cf_vwqYhEFwzPyfCErS8uQ77is1wFLvr9BgVi6cTfbFM48",
22 "filter": {
23 "type": "equals",
24 "value": "sub_product_5678"
25 }
26 }
27 }
28 ]
29}

Use any_array_value to match events that have any address in Maryland, USA

1{
2 "type": "field_accessor",
3 "field": "data",
4 "filter": {
5 "type": "field_accessor",
6 "field": "addresses",
7 "filter": {
8 "type": "any_array_value",
9 "filter": {
10 "type": "and",
11 "filters": [
12 {
13 "type": "field_accessor",
14 "field": "state",
15 "filter": {
16 "type": "equals",
17 "value": "MD"
18 }
19 },
20 {
21 "type": "field_accessor",
22 "field": "country",
23 "filter": {
24 "type": "equals",
25 "value": "US"
26 }
27 }
28 ]
29 }
30 }
31 }
32}