When filters run
Filters run once, when a received message first enters the credential’s mailbox. Editing, reordering or deleting filters does not re-sort mail that has already arrived. To run the current filters against existing mail, use apply.- Filters only see received mail. Appended messages, drafts and Sent copies are not filtered.
- Enabled filters run in their saved order, and every matching filter’s actions run. A
stopaction orstopProcessing: trueskips the filters after it. - If a filter fails for a message (for example, a
move_tofolder was deleted), that filter’s actions are discarded. Other filters still run. If no filter moves the message, it lands inINBOX, orJunkwhen the junk filter says so.
Manage filters
Use an account API key with/api/e2/mailboxes/{mailboxId}/filters, or a mailbox password with /api/e2/mailboxes/me/filters when the credential’s selfService.filters is enabled. See Access and Limits.
The list returns
data and pagination: { limit, offset, total, hasMore }; limit defaults to 50 and cannot exceed 100. POST returns 201 with the new filter, and a mailbox that already has 100 filters returns 409. PATCH replaces conditions or actions as whole lists. DELETE returns {"id":"FILTER_ID","deleted":true}. reorder must list every filter of the mailbox exactly once; otherwise nothing changes and it returns 409. It returns the filters in their new order as data.
Responses also include
id, position, createdAt and updatedAt.
Conditions
Each condition has afield, an operator and, for most operators, a value. Text comparisons ignore case. Regular expressions are not supported.
The text operators are
contains, not_contains, equals, not_equals, starts_with and ends_with. domain_is matches the exact domain of an address, without subdomains, and accepts example.com or @example.com. For an address field with several addresses, a positive operator matches when any address matches, and not_contains or not_equals match only when none does.
For exists, omit value or use true to match when the header or Cc is present; use false to match when it is missing.
header conditions treat them as missing.
Actions
A filter can have at most one
move_to or move_to_trash, and can’t have both mark_junk and mark_not_junk. If several matching filters move a message, the last one wins. A message moved to another folder is no longer in INBOX or the scope folders, like any other move. Filters can’t forward, reply or permanently delete mail.
A filter’s mark_junk or mark_not_junk is a decision for this mailbox, like moving the message in an email client. It doesn’t change the account’s verdict or webhooks. See Junk Filter.
Limits
Sieve scripts and ManageSieve are not supported.
Apply filters to existing mail
POST /mailboxes/{id}/filters/apply runs the enabled filters against received messages already in a folder, in UID order. POST /mailboxes/{id}/filters/{filterId}/apply runs only one filter, which must be enabled (otherwise 409). Both need a Read & write mailbox and can’t run on Scopes/* folders; either returns 403.
folder is required. Each request examines at most 500 messages; limit defaults to 500.
hasMore is true, repeat the request with afterUid set to lastUid. Repeating apply with unchanged filters makes no further changes. Changing the enabled filters or their order creates a new version of the rule set. Applying all filters then runs their actions again on the batch, including unchanged rules; this can restore flags or moves you had undone manually.
When applying all filters, an earlier matching stop still prevents later filters from running, even if only a later filter changed. Applying one filter runs just that filter. When the matching actions only add flags or keywords, the message stays in the folders it is already in; move and junk actions can move it.
Junk Filter
Set a per-mailbox spam level and allow or block senders.
Access and Limits
Restrict protocols and IP addresses, and let mailbox users manage their own filters.