REST Resource: users.settings.filters

Resource: Filter

Resource definition for Gmail filters. Filters apply to specific messages instead of an entire email thread.

JSON representation
{
  "id": string,
  "criteria": {
    object (Criteria)
  },
  "action": {
    object (Action)
  }
}
Fields
id

string

The server assigned ID of the filter.

criteria

object (Criteria)

Matching criteria for the filter.

action

object (Action)

Action that the filter performs.

Criteria

Message matching criteria.

JSON representation
{
  "from": string,
  "to": string,
  "subject": string,
  "query": string,
  "negatedQuery": string,
  "hasAttachment": boolean,
  "excludeChats": boolean,
  "size": integer,
  "sizeComparison": enum (SizeComparison)
}
Fields
from

string

The sender's display name or email address.

to

string

The 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@gmail.com". This field is case-insensitive.

subject

string

Case-insensitive phrase found in the message's subject. Trailing and leading whitespace are be trimmed and adjacent spaces are collapsed.

query

string

Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread".

negatedQuery

string

Only return messages not matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread".

hasAttachment

boolean

Whether the message has any attachment.

excludeChats

boolean

Whether the response should exclude chats.

size

integer

The size of the entire RFC822 message in bytes, including all headers and attachments.

sizeComparison

enum (SizeComparison)

How the message size in bytes should be in relation to the size field.

SizeComparison

Determines how the size field should be compared to the message size.

Enums
unspecified
smaller Find messages smaller than the given size.
larger Find messages larger than the given size.

Action

A set of actions to perform on a message.

JSON representation
{
  "addLabelIds": [
    string
  ],
  "removeLabelIds": [
    string
  ],
  "forward": string
}
Fields
addLabelIds[]

string

List of labels to add to the message.

removeLabelIds[]

string

List of labels to remove from the message.

forward

string

Email address that the message should be forwarded to.

Methods

create

Creates a filter.

delete

Immediately and permanently deletes the specified filter.

get

Gets a filter.

list

Lists the message filters of a Gmail user.