create_filter
Create a Gmail filter to auto-label or archive incoming mail by sender, subject, size, or query. Optionally apply the same label changes to existing messages to clean your inbox.
Instructions
Create a Gmail filter: matching incoming mail automatically gets the given label actions. Give at least one criterion and at least one action. Actions are label add/remove only (labels by name or id; an unknown name in addLabels is auto-created). Common recipes: skip the inbox → removeLabels ['INBOX']; auto-mark-read → removeLabels ['UNREAD']; auto-trash → addLabels ['TRASH']; star → addLabels ['STARRED']; file under a label → addLabels ['Receipts']. A filter only affects mail arriving AFTER it's created; set applyToExisting:true to ALSO apply the same actions once to mail already in the mailbox (builds a Gmail search from the criteria and runs a bulk modify — same unverified-index caveat as bulk_modify — the sweep acts on what the index returns, which can be badly stale on read state; up to maxMessages, default 1000). USE WHEN: setting up a persistent auto-triage rule (e.g. 'always archive + label newsletters from x'), optionally cleaning up the existing backlog too. NOTE: forwarding filters are intentionally not supported — mailwarden creates no send/exfiltration path. SIDE EFFECTS: adds a server-side rule affecting future mail (reversible via delete_filter); with applyToExisting also modifies existing messages. Requires gmail.settings.basic.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | ||
| from | No | ||
| size | No | ||
| query | No | ||
| subject | No | ||
| addLabels | No | ||
| maxMessages | No | ||
| excludeChats | No | ||
| negatedQuery | No | ||
| removeLabels | No | ||
| hasAttachment | No | ||
| sizeComparison | No | ||
| applyToExisting | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ||
| applied | Yes | ||
| forward | No | ||
| criteria | Yes | ||
| addLabelIds | Yes | ||
| removeLabelIds | Yes |