> For the complete documentation index, see [llms.txt](https://docs.reflag.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reflag.com/product-handbook/concepts/filter.md).

# Filter

### Definition

A filter, in Reflag, is a mechanism that is used to check if entities such as [user](/product-handbook/concepts/user.md), [company](/product-handbook/concepts/company.md), [event](/product-handbook/concepts/event.md), etc. match a set of predicates. Filters can also be aggregated into logical expressions, thus, facilitating advanced use cases.

Reflag supports the following filter types:

* [Company attribute](/product-handbook/concepts/company.md#attributes) filter, that can be used to check company attributes,
* Company [flag metrics](/product-handbook/concepts/feature.md#metrics) filter, which allows checking flag metrics for a given company,
* [User attribute](/product-handbook/concepts/user.md#attributes) filter, used to check user attributes,
* [Event attribute](/product-handbook/concepts/event.md#attributes) filter, used to check event attributes,
* Company [segment](/product-handbook/concepts/segment.md) filter, can be used to check a company's membership in a segment,
* [Flag access](/product-handbook/concepts/feature.md#access) filter, can be used to check whether a company has access to a flag,
* [Gradual rollout](/product-handbook/feature-rollouts.md#gradually-roll-out-your-flag) filter, is used in advanced scenarios to evaluate whether a company matches a rollout bracket,
* [Other context](/product-handbook/concepts/targeting-rules.md#evaluation-context) filter, used when rules can access additional context, in addition to user and company attributes.

### Company attribute filter

This filter can be used to check company attributes against a set of predicates. The attributes include `First seen` and `Last seen`, which are maintained by Reflag. You can use any attribute name that your application sends to Reflag.

### Company flag metrics

This filter allows checking company-level flag metrics. These metrics include `Event count`, `First used`, `Last used`, and more.

### User attribute filter

This filter can be used to check user attributes against a set of predicates. You can use any attribute name that your application sends to Reflag when updating a user.

### Event attribute filter

This filter can be used to check event attributes against a set of predicates. You can use any attribute name that your application sends to Reflag when sending track events.

### Company segment filter

This filter can be used to check if a given company is (or not) included in a given segment. The filter essentially evaluates the segment's filter against the company.

### Flag access filter

This filter can be used to check if a given company has access to a given flag. The filter evaluates the flag's targeting rules against the provided company and skips any non-company attribute filters.

### Gradual rollout filter

This filter is used by flag access targeting when enabling gradual rollout. It brackets the pool of companies with a predictable hashing algorithm and checks whether the company falls within the rollout percentage.

### Other context filter

This filter can be used to check `other` context attributes against a set of predicates. You can use any attribute name that your application sends to Reflag when evaluating flag access.

{% hint style="warning" %}

* Company attribute filters using `First seen` and `Last seen` attributes cannot be used in targeting rules,
* Company flag metrics filters are not supported in targeting rules,
* Event attribute filter is only used in event-based flags and automatic feedback surveys,
* Gradual rollout filter is only used in flag access targeting rules,
* Other context filter is only used in flag access targeting rules,

Any filters that build on other filters inherit the restrictions of the filters they are based on.
{% endhint %}

### Next steps

* Learn in depth how to use filters in [setting up flag access rules](/product-handbook/feature-rollouts/feature-targeting-rules.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reflag.com/product-handbook/concepts/filter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
