They are declarative pattern-matching rules, modeled after AWS EventBridge patterns.
Given the following custom event payload:
The following event filter would match the event:
For an event pattern to match an event, the event must contain all the field names listed in the event pattern. The field names must also appear in the event with the same nesting structure.
The value of each field name in the event pattern must be an array of strings, numbers, or booleans. The event pattern matches the event if the value of the field name in the event is equal to any of the values in the array.
Effectively, each array is an OR condition, and the entire event pattern is an AND condition.
So the above event filter will match because status == "ACCEPTED"
, and it would also match if status == "REJECTED"
.
String filters are used to match string values within the event payload. You can filter events based on exact string matches, case-insensitive matches, starts-with, ends-with, and more.
Examples:
name: ["John"]
: Triggers the job if the name field in the event payload is exactly “John”.name: [{ $startsWith: "Jo" }]
: Triggers the job if the name field starts with “Jo”.name: [{ $endsWith: "hn" }]
: Triggers the job if the name field ends with “hn”.name: [{ $ignoreCaseEquals: "john" }]
: Triggers the job if the name field is equal to “john” regardless of case.Boolean filters are used to filter events based on boolean values within the event payload.
Examples:
paidPlan: [true]
: Triggers the job if the PaidPlan
field in the event payload is true
.isAdmin: [false]
: Triggers the job if the isAdmin
field in the event payload is false
.Number filters are used to filter events based on numeric values within the event payload. It can also be used to perform numeric comparisons on values within the event payload.
Examples:
age [18]
: Triggers the job if the age
field in the event payload is equal to 18
.score: [{ $gt: 90 }]
: Triggers the job if the score field is greater than 90
.score: [{ $gte: 90 }]
: Triggers the job if the score field is greater than or equal to 90
.score: [{ $lt: 90 }]
: Triggers the job if the score field is less than 90
.score: [{ $lte: 90 }]
: Triggers the job if the score field is less than or equal to 90
.age: [{ $gt: 20 }, { $lt: 40 }]
: Triggers the job if the age
field is greater than 20 and less than 40.score: [{ $between: [90, 110] }]
: Triggers the job if the score
field is between 90 and 110.Array filters are used to filter events based on the content of arrays within the event payload.
Examples:
hobbies: [{ $includes: "reading" }]
: Triggers the job if the hobbies array includes the value “reading”.Existence filters are used to filter events based on the presence or absence of certain keys within the event payload.
Examples:
name: [{ $exists: true }]
: Triggers the job if the name
field exists in the event payload.foo: [{ $exists: false }]
: Triggers the job if the foo field does not exist in the event payload.Filters can be combined to create more complex conditions for triggering jobs.
Examples:
name: ["Alice"], age: [30]
: Triggers the job if the name is “Alice” and the age is 30.name: ["Alice"], age: [{ $gt: 20 }, { $lt: 40 }]
: Triggers the job if the name is “Alice” and the age is between 20 and 40.name: ["Alice", "Bob"]
: Triggers the job if the name is either “Alice” or “Bob”.name: ["Alice", "Bob"], age: [30]
: Triggers the job if the name is either “Alice” or “Bob” and the age is 30.Here is an example of a Stripe Trigger with an Event Filter:
The job is triggered by the onCustomerSubscriptionCreated
event from Stripe. It is configured to trigger only when certain conditions are met. In this case, the job is triggered when a subscription is created with the following condition:
Here is an example of a Supabase Trigger with an Event Filter:
They are declarative pattern-matching rules, modeled after AWS EventBridge patterns.
Given the following custom event payload:
The following event filter would match the event:
For an event pattern to match an event, the event must contain all the field names listed in the event pattern. The field names must also appear in the event with the same nesting structure.
The value of each field name in the event pattern must be an array of strings, numbers, or booleans. The event pattern matches the event if the value of the field name in the event is equal to any of the values in the array.
Effectively, each array is an OR condition, and the entire event pattern is an AND condition.
So the above event filter will match because status == "ACCEPTED"
, and it would also match if status == "REJECTED"
.
String filters are used to match string values within the event payload. You can filter events based on exact string matches, case-insensitive matches, starts-with, ends-with, and more.
Examples:
name: ["John"]
: Triggers the job if the name field in the event payload is exactly “John”.name: [{ $startsWith: "Jo" }]
: Triggers the job if the name field starts with “Jo”.name: [{ $endsWith: "hn" }]
: Triggers the job if the name field ends with “hn”.name: [{ $ignoreCaseEquals: "john" }]
: Triggers the job if the name field is equal to “john” regardless of case.Boolean filters are used to filter events based on boolean values within the event payload.
Examples:
paidPlan: [true]
: Triggers the job if the PaidPlan
field in the event payload is true
.isAdmin: [false]
: Triggers the job if the isAdmin
field in the event payload is false
.Number filters are used to filter events based on numeric values within the event payload. It can also be used to perform numeric comparisons on values within the event payload.
Examples:
age [18]
: Triggers the job if the age
field in the event payload is equal to 18
.score: [{ $gt: 90 }]
: Triggers the job if the score field is greater than 90
.score: [{ $gte: 90 }]
: Triggers the job if the score field is greater than or equal to 90
.score: [{ $lt: 90 }]
: Triggers the job if the score field is less than 90
.score: [{ $lte: 90 }]
: Triggers the job if the score field is less than or equal to 90
.age: [{ $gt: 20 }, { $lt: 40 }]
: Triggers the job if the age
field is greater than 20 and less than 40.score: [{ $between: [90, 110] }]
: Triggers the job if the score
field is between 90 and 110.Array filters are used to filter events based on the content of arrays within the event payload.
Examples:
hobbies: [{ $includes: "reading" }]
: Triggers the job if the hobbies array includes the value “reading”.Existence filters are used to filter events based on the presence or absence of certain keys within the event payload.
Examples:
name: [{ $exists: true }]
: Triggers the job if the name
field exists in the event payload.foo: [{ $exists: false }]
: Triggers the job if the foo field does not exist in the event payload.Filters can be combined to create more complex conditions for triggering jobs.
Examples:
name: ["Alice"], age: [30]
: Triggers the job if the name is “Alice” and the age is 30.name: ["Alice"], age: [{ $gt: 20 }, { $lt: 40 }]
: Triggers the job if the name is “Alice” and the age is between 20 and 40.name: ["Alice", "Bob"]
: Triggers the job if the name is either “Alice” or “Bob”.name: ["Alice", "Bob"], age: [30]
: Triggers the job if the name is either “Alice” or “Bob” and the age is 30.Here is an example of a Stripe Trigger with an Event Filter:
The job is triggered by the onCustomerSubscriptionCreated
event from Stripe. It is configured to trigger only when certain conditions are met. In this case, the job is triggered when a subscription is created with the following condition:
Here is an example of a Supabase Trigger with an Event Filter: