Skip to content

Google: Creates a filter Note: you can only create a maximum of 1,000 filters For more information, see Manage Gmail filters (https: developers google com workspace gmail api guides filter settings) — request body — body criteria

Creates a filter. Note: you can only create a maximum of 1,000 filters. For more information, see [Manage Gmail filters](https://developers.google.com/workspace/gmail/api/guides/filter_settings).: request body, field body / criteria. Complete fields and constraints for contract 2026-10-27.

API reference · Contract 2026-10-27

SDK schema: Creates a filter. Note: you can only create a maximum of 1,000 filters For more information, see Manage Gmail filters (https: developers google com workspace gmail api guides filter settings) — request body — body criteria

FieldTypePresenceDescription and constraints
$objectRootMessage matching criteria.
excludeChatsbooleanOptionalWhether the response should exclude chats.
fromstringOptionalThe sender’s display name or email address.
hasAttachmentbooleanOptionalWhether the message has any attachment.
negatedQuerystringOptionalOnly return messages not matching the specified query. Supports the same query format as the Gmail search box. For example, `“from:someuser@example.com rfc822msgid: is:unread”`.
querystringOptionalOnly return messages matching the specified query. Supports the same query format as the Gmail search box. For example, `“from:someuser@example.com rfc822msgid: is:unread”`.
sizeintegerOptionalThe size of the entire RFC822 message in bytes, including all headers and attachments.
Format: int32
sizeComparisonstringOptionalHow the message size in bytes should be in relation to the size field.
One of: unspecified, smaller, larger
subjectstringOptionalCase-insensitive phrase found in the message’s subject. Trailing and leading whitespace are be trimmed and adjacent spaces are collapsed.
tostringOptionalThe recipient’s display name or email address. Includes recipients in the “to”, “cc”, and “bcc” header fields. You can use simply the local part of the email address. For example, “example” and “example@” both match “example@example.com”. This field is case-insensitive.

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.