This guide assumes familiarity with building workflows. For an introduction, see How to Build a Workflow. For details on working with input fields, see Fields and Fieldsets.
Example: Adding a Filter Step
Let’s walk through an example of adding a filter step to a workflow. We’ll assume you’ve already configured a first step as described in How to Build a Workflow. For this example, let’s say it’s a “New Email in Gmail” trigger.Finding the Filter by Zapier App
First, we need to find the Filter by Zapier app. You can search for it using the GET /v2/apps endpoint:id: e85bcf45-505b-4acb-b7e8-4c3a81d49afb. We’ll use this in the next step.
Getting the Filter Action
Now that we have the app ID, we can retrieve the filter action using the GET /v2/actions endpoint withaction_type=FILTER:
action_type of FILTER, which distinguishes it from standard READ and WRITE actions.
Configuring Filter Inputs
To get the available inputs, make a request to the POST /v2/actions/{action_id}/inputs endpoint:Understanding Filter Criteria
Each fieldset in the response represents a filter condition. A filter condition is a single rule like “email subject contains ‘urgent’” or “lead status equals ‘qualified’”. By default at least one filter condition must be configured. You can increase the number of filter conditions using thefilter_criteria_count input.
Filter Criteria Count
Thefilter_criteria_count input controls how many filter conditions are available. Since it has format: "SELECT", we need to fetch its available choices from the POST /v2/actions/{action_id}/inputs/{input_id}/choices endpoint:
Configuring Multiple Filter Conditions
When you setfilter_criteria_count to a value greater than 1, you’ll need to refetch the inputs (since invalidates_input_fields is true). Let’s see what happens when we request 2 filter conditions:
- A second fieldset (
filter_criteria_2) - A new
boolean_operatorinput field
Boolean Operator
Theboolean_operator input appears whenever filter_criteria_count is greater than 1. It determines how multiple filter conditions are combined. Let’s fetch its choices:
boolean_operator allows you to specify whether:
- All conditions must match (
and): The workflow continues only if every filter condition is satisfied - At least one condition must match (
or): The workflow continues if any filter condition is satisfied
Filter Match Rules
Each filter condition has afilter_criteria_{n}_match field that determines the comparison method. Since this is a SELECT field, we need to fetch its choices:
- Text comparisons: contains, exactly matches, starts with, ends with, etc.
- Number comparisons: greater than, less than
- Date/time comparisons: after, before, equals
- Boolean comparisons: is true, is false
- Existence checks: exists, does not exist
The Key Field
The
filter_criteria_{n}_key field must contain one and only one field reference in the format {{previous_step_alias.field_id}} or {{field_id}} (for 2-step workflows). It cannot contain any other text or multiple field references.gmail_trigger and outputs a field called subject, the key field should be set to:
The Value Field
Depending on the match rule selected forfilter_criteria_{n}_match, a filter_criteria_{n}_value field may be returned when you refetch the inputs. This field represents the value to compare against.
For example:
- Match rules like “contains”, “exactly matches”, or “is greater than” require a value to compare against, so
filter_criteria_{n}_valuewill appear - Match rules like “exists” or “does not exist” don’t need a comparison value, so
filter_criteria_{n}_valuewill not appear
Since
filter_criteria_{n}_match has invalidates_input_fields: true, you’ll need to refetch the inputs after selecting a match rule to see if a value field is required. For more details on this pattern, see the invalidation and dependency flow documentation.Testing a Filter Step
Once you’ve configured the filter inputs, you can test the filter step using the POST /v2/actions/{action_id}/test endpoint. Unlike actual use of the Filter, “raw” values are allowed as there is no prior/incoming field to reference.can_continue field that indicates whether the filter conditions were met. In this example, both conditions were satisfied, so the workflow would continue.
Getting Filter Outputs
To retrieve the output fields from a filter step, use the POST /v2/actions/{action_id}/outputs endpoint:can_continue, which indicates whether the filter conditions were met. While this field can be referenced in subsequent steps, filter steps are typically used for their side effect of halting workflow execution when conditions aren’t met, rather than for their output data.
Complete Example
Here’s a complete example of adding a filter step to a workflow. This workflow triggers on new Gmail emails and only continues if the email subject contains “urgent”:Note that filter steps don’t require authentication, so the
authentication field is always set to null.