REST Resource: users.settings.filters
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
资源:过滤器
Gmail 过滤器的资源定义。过滤器会应用于特定邮件,而不是整个电子邮件会话。
JSON 表示法 |
{
"id": string,
"criteria": {
object (Criteria )
},
"action": {
object (Action )
}
} |
字段 |
id |
string
服务器分配给过滤器的 ID。
|
criteria |
object (Criteria )
过滤条件的匹配条件。
|
action |
object (Action )
过滤器执行的操作。
|
条件
JSON 表示法 |
{
"from": string,
"to": string,
"subject": string,
"query": string,
"negatedQuery": string,
"hasAttachment": boolean,
"excludeChats": boolean,
"size": integer,
"sizeComparison": enum (SizeComparison )
} |
字段 |
from |
string
发件人的显示名称或电子邮件地址。
|
to |
string
收件人的显示名称或电子邮件地址。包括“收件人”“抄送”和“密送”标头字段中的收件人。您只需使用电子邮件地址的本地部分即可。例如,“example”和“example@”都与“example@gmail.com”匹配。此字段不区分大小写。
|
subject |
string
邮件主题中不区分大小写的字词。系统会去除尾随空格和前导空格,并合并相邻空格。
|
query |
string
仅返回与指定查询匹配的消息。支持与 Gmail 搜索框相同的查询格式。例如 "from:someuser@example.com rfc822msgid:<somemsgid@example.com>
is:unread" 。
|
negatedQuery |
string
仅返回与指定查询不匹配的消息。支持与 Gmail 搜索框相同的查询格式。例如 "from:someuser@example.com rfc822msgid:<somemsgid@example.com>
is:unread" 。
|
hasAttachment |
boolean
邮件是否包含任何附件。
|
excludeChats |
boolean
响应是否应排除聊天内容。
|
size |
integer
整个 RFC822 邮件的大小(以字节为单位),包括所有标头和附件。
|
sizeComparison |
enum (SizeComparison )
消息大小(以字节为单位)与大小字段之间的关系。
|
SizeComparison
枚举 |
unspecified |
|
smaller |
查找小于指定大小的邮件。 |
larger |
查找大于给定大小的邮件。 |
操作
JSON 表示法 |
{
"addLabelIds": [
string
],
"removeLabelIds": [
string
],
"forward": string
} |
字段 |
addLabelIds[] |
string
要添加到邮件中的标签列表。
|
removeLabelIds[] |
string
要从邮件中移除的标签的列表。
|
forward |
string
应将邮件转发到的电子邮件地址。
|
方法 |
|
创建过滤条件。 |
|
立即永久删除指定的过滤条件。 |
|
获取过滤器。 |
|
列出 Gmail 用户的邮件过滤器。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# REST Resource: users.settings.filters\n\n- [Resource: Filter](#Filter)\n - [JSON representation](#Filter.SCHEMA_REPRESENTATION)\n- [Criteria](#Criteria)\n - [JSON representation](#Criteria.SCHEMA_REPRESENTATION)\n- [SizeComparison](#SizeComparison)\n- [Action](#Action)\n - [JSON representation](#Action.SCHEMA_REPRESENTATION)\n- [Methods](#METHODS_SUMMARY)\n\nResource: Filter\n----------------\n\nResource definition for Gmail filters. Filters apply to specific messages instead of an entire email thread.\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"id\": string, \"criteria\": { object (/workspace/gmail/api/reference/rest/v1/users.settings.filters#Criteria) }, \"action\": { object (/workspace/gmail/api/reference/rest/v1/users.settings.filters#Action) } } ``` |\n\n| Fields ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `id` | `string` The server assigned ID of the filter. |\n| `criteria` | `object (`[Criteria](/workspace/gmail/api/reference/rest/v1/users.settings.filters#Criteria)`)` Matching criteria for the filter. |\n| `action` | `object (`[Action](/workspace/gmail/api/reference/rest/v1/users.settings.filters#Action)`)` Action that the filter performs. |\n\nCriteria\n--------\n\nMessage matching criteria.\n\n| JSON representation |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"from\": string, \"to\": string, \"subject\": string, \"query\": string, \"negatedQuery\": string, \"hasAttachment\": boolean, \"excludeChats\": boolean, \"size\": integer, \"sizeComparison\": enum (/workspace/gmail/api/reference/rest/v1/users.settings.filters#SizeComparison) } ``` |\n\n| Fields ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `from` | `string` The sender's display name or email address. |\n| `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. |\n| `subject` | `string` Case-insensitive phrase found in the message's subject. Trailing and leading whitespace are be trimmed and adjacent spaces are collapsed. |\n| `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:\u003csomemsgid@example.com\u003e is:unread\"`. |\n| `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:\u003csomemsgid@example.com\u003e is:unread\"`. |\n| `hasAttachment` | `boolean` Whether the message has any attachment. |\n| `excludeChats` | `boolean` Whether the response should exclude chats. |\n| `size` | `integer` The size of the entire RFC822 message in bytes, including all headers and attachments. |\n| `sizeComparison` | `enum (`[SizeComparison](/workspace/gmail/api/reference/rest/v1/users.settings.filters#SizeComparison)`)` How the message size in bytes should be in relation to the size field. |\n\nSizeComparison\n--------------\n\nDetermines how the size field should be compared to the message size.\n\n| Enums ||\n|---------------|--------------------------------------------|\n| `unspecified` | |\n| `smaller` | Find messages smaller than the given size. |\n| `larger` | Find messages larger than the given size. |\n\nAction\n------\n\nA set of actions to perform on a message.\n\n| JSON representation |\n|----------------------------------------------------------------------------------------|\n| ``` { \"addLabelIds\": [ string ], \"removeLabelIds\": [ string ], \"forward\": string } ``` |\n\n| Fields ||\n|--------------------|-----------------------------------------------------------------|\n| `addLabelIds[]` | `string` List of labels to add to the message. |\n| `removeLabelIds[]` | `string` List of labels to remove from the message. |\n| `forward` | `string` Email address that the message should be forwarded to. |\n\n| Methods ------- ||\n|------------------------------------------------------------------------------------|-----------------------------------------------------------|\n| ### [create](/workspace/gmail/api/reference/rest/v1/users.settings.filters/create) | Creates a filter. |\n| ### [delete](/workspace/gmail/api/reference/rest/v1/users.settings.filters/delete) | Immediately and permanently deletes the specified filter. |\n| ### [get](/workspace/gmail/api/reference/rest/v1/users.settings.filters/get) | Gets a filter. |\n| ### [list](/workspace/gmail/api/reference/rest/v1/users.settings.filters/list) | Lists the message filters of a Gmail user. |"]]