监控电子邮件

如需使用 Email Audit API 设置电子邮件监控,管理员需要设置一个日期范围,以便审核员以附件形式接收特定用户的已发送和已接收电子邮件的副本。每天创建和删除监控对象的请求数上限为 1,000 个。此限制适用于每个网域,包括任何管理员在一天内发出的所有请求。

受监控的电子邮件场景包含三种类型的用户:

  • 管理员 - 任何网域管理员都可以使用电子邮件审核 API 的监控资源来创建、检索、更新和删除电子邮件监控。此外,管理员还可以使用该 API 下载邮箱。这些操作只能在管理员行使控制权的网域内完成。

  • 源用户 - 源用户是指接收或发送消息的用户,这些消息正由监控目标用户进行审核。任何网域管理员或账号用户都可以是源用户。源用户必须与管理员和目标用户位于同一网域中。

  • 目标用户 - 目标用户是接收已审核电子邮件的审核员。

    • 接收所有入站和出站电子邮件的密送 (Bcc) 副本,包括入站和出站附件、转发的邮件以及通过移动设备发送的电子邮件。
    • 网域管理员可以选择为目标用户启用其他审核功能。可选功能包括审核已保存的电子邮件草稿,以及审核与网域内或网域外的其他用户进行的已归档 Hangouts 聊天。
    • 即使目标用户收到了密送邮件,源用户账号中可访问的邮件标头中也不会显示密送关联。
    • 每封经过审核的电子邮件都会以电子邮件附件的形式发送给目标用户。网域管理员可以将这些消息配置为完整电子邮件或仅包含邮件头。
    • 此目标用户必须在受监控的网域中拥有有效的电子邮件账号。此网域必须与管理员和来源用户关联的网域相同。
    • 目标用户可以是网域内的管理员或用户。 并且,此目标用户可以切换角色,成为由另一目标用户审核的源用户,而后者会收到发送给第一个目标用户的所有经过审核的电子邮件的副本。
    • 网域管理员可以为每个唯一的“目标用户 - 源用户”对创建一个受审核的电子邮件监控器。换句话说,审核关系是从一个目标用户到一个源用户的关系。每次审核都是使用 API 监控资源完成的。通过使用多个 API 监控器,目标用户可以审核网域中的许多用户。此外,使用多个 API 监控器,许多目标用户可以审核一个源用户。
    • 如果为“目标用户 - 源用户”对创建了额外的 API 监控器或更新了现有的 API 监控器,则最后创建的监控器会取代此对的任何先前存在的监控器。基本上,这就是更新 API 监控的方式。如需详细了解如何更新监控器,请参阅更新电子邮件监控器

创建电子邮件监控事件

如需创建电子邮件监控工具,请发送以下 POST 请求,其中包含电子邮件监控工具资源:

POST https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/DOMAIN_NAME/SOURCE_USERNAME

替换以下内容:

  • DOMAIN_NAME:Google Workspace 域名,例如 example.com。
  • SOURCE_USERNAME:您要监控的用户名。

POST 请求包含以下 Content-type 标头:

Content-type: application/atom+xml

如需查看可在电子邮件监控请求中使用的参数的完整列表,请参阅资源:monitor

创建新监控器的示例

该示例使用以下参数:

  • 要接受审核的用户是 amal@example.com
  • destUserName为“izumi”。
  • beginDate为“June 15, 2022, 00:00 hours”。
  • endDate为“June 30, 2022, 23:20 hours”。
  • incomingEmailMonitorLevel为“FULL_MESSAGE”。
  • outgoingEmailMonitorLevel为“HEADER_ONLY”。
  • draftMonitorLevel为“FULL_MESSAGE”。
  • chatMonitorLevel为“FULL_MESSAGE”。

协议

POST https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal

<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
   <apps:property name='destUserName' value='izumi'/>
   <apps:property name='beginDate' value='2022-06-15 00:00'/>
   <apps:property name='endDate' value='2022-06-30 23:20'/>
   <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
   <apps:property name='outgoingEmailMonitorLevel' value='HEADER_ONLY'/>
   <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
   <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
</atom:entry>

如果成功,服务器将返回 201 CREATED 状态代码以及一个 AtomPub 条目,其中包含显示新监控设置的 entry 元素:

<entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
    <id>https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/id</id>
    <updated>2022-04-17T15:02:45.646Z</updated/>
    <link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/id'/>
    <link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/id'/>
    <apps:property name='destUserName' value='izumi'/>
    <apps:property name='beginDate' value='2022-06-15 00:00'/>
    <apps:property name='endDate' value='2022-06-30 23:20'/>
    <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
    <apps:property name='outgoingEmailMonitorLevel' value='HEADER_ONLY'/>
    <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
    <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
</entry>

Java

import java.util.Calendar;
import com.google.gdata.client.appsforyourdomain.audit.AuditService;
import com.google.gdata.data.appsforyourdomain.generic.GenericEntry;
import com.google.gdata.client.appsforyourdomain.audit.MailMonitor;
...

MailMonitor monitor = new MailMonitor();
Calendar beginDate = Calendar.getInstance();
beginDate.set(2022, Calendar.JUNE, 15, 0, 0)
monitor.setBeginDate(beginDate.getTime());
Calendar endDate = Calendar.getInstance();
endDate.set(2022, Calendar.JUNE, 30, 23, 20);
monitor.setEndDate(endDate.getTime());
monitor.setIncomingEmailMonitorLevel("FULL_MESSAGE");
monitor.setOutgoingEmailMonitorLevel("HEADER_ONLY");
monitor.setDraftMonitorLevel("FULL_MESSAGE");
monitor.setChatMonitorLevel("FULL_MESSAGE");
monitor.setDestUserName("izumi");

AuditService service = new AuditService("admin@example.com", "p@55w0rd", "example.com", "example.com-auditapp-v1");
GenericEntry entry = service.createMailMonitor("amal", monitor);

.NET

using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

MailMonitor monitor = new MailMonitor();
monitor.BeginDate = new DateTime(2022, 6, 15);
monitor.EndDate = new DateTime(2022, 6, 30, 23, 20, 0);
monitor.IncomingEmailMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.OutgoingEmailMonitorLevel = MonitorLevel.HEADER_ONLY;
monitor.DraftMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.ChatMonitorLevel = MonitorLevel.FULL_MESSAGE;
monitor.DestinationUserName = "izumi";

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("admin@example.com", "p@55w0rd");
MailMonitor monitorEntry = service.CreateMailMonitor("amal", monitor);

更新电子邮件监控事件

当更新具有相同源用户和目标用户的监控时,初始监控的属性设置会被新设置替换。

如需更新电子邮件监控器中的审核配置,请向监控器 Feed 的 URI 发送 POST 请求,并添加 Authorization 标头:

POST https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/DOMAIN_NAME/SOURCE_USERNAME

替换以下内容:

  • DOMAIN_NAME:Google Workspace 域名,例如 example.com。
  • SOURCE_USERNAME:您要更新的电子邮件监控器的用户名。

更新电子邮件监控器的示例

此示例通过更新必需属性 endDate 和可选属性 chatMonitorLevel,更新了创建电子邮件监控器的示例中创建的监控器。此示例使用以下参数:

  • 新的 endDateAugust 30, 2022, 23:20 hours
  • chatMonitorLevel 现为 HEADER_ONLY
  • 要接受审核的用户仍为 amal@example.com
  • destUserName 仍然为 izumi

未更新的显示器属性会恢复为默认值。例如,在此示例中,incomingEmailMonitorLeveloutgoingEmailMonitorLevel 属性恢复为 FULL_MESSAGEdraftMonitorLevel 恢复为 NONE

协议

POST https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal

<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
    <apps:property name='destUserName' value='izumi'/>
    <apps:property name='endDate' value='2022-08-30 23:20'/>
    <apps:property name='chatMonitorLevel' value='HEADER_ONLY'/>
</atom:entry>

如果成功,服务器将返回 201 CREATED 状态代码以及包含更新后的 entry 元素的 AtomPub 条目。未更新且显示在响应中的属性会恢复为默认值。

<entry>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
    <id>https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi</id>
    <updated>2022-08-20T00:28:57.319Z</updated>
    <link rel='self' type='application/atom+xml' href="https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi" />
    <link rel='edit' type='application/atom+xml' href="https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi" />
    <apps:property name='chatMonitorLevel' value='HEADER_ONLY' />
    <apps:property name='destUserName' value='izumi' />
    <apps:property name='endDate' value='2022-08-30 23:20' />
</entry>

Java

import java.util.Calendar;
import com.google.gdata.client.appsforyourdomain.audit.AuditService;
import com.google.gdata.client.appsforyourdomain.audit.MailMonitor;
import com.google.gdata.data.appsforyourdomain.generic.GenericEntry;
...

MailMonitor monitor = new MailMonitor();
Calendar endDate = Calendar.getInstance();
endDate.set(2022, Calendar.AUGUST, 30, 23, 20);
monitor.setEndDate(endDate.getTime());
monitor.setChatMonitorLevel("HEADER_ONLY");
monitor.setDestUserName("izumi");

AuditService service = new AuditService("admin@example.com", "p@55w0rd", "example.com", "example.com-auditapp-v1");
GenericEntry entry = service.createMailMonitor("amal", monitor);

.NET

using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

MailMonitor monitor = new MailMonitor();
monitor.EndDate = new DateTime(2022, 8, 30, 23, 20, 0);
monitor.ChatMonitorLevel = MonitorLevel.HEADER_ONLY;
monitor.DestinationUserName = "izumi";

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("admin@example.com", "p@55w0rd");
MailMonitor monitorEntry = service.CreateMailMonitor("amal", monitor);

检索源用户的所有电子邮件监控设置

如需检索与来源用户关联的所有监控,请向监控 Feed URI 发出 HTTP GET 请求,使用 UTC 格式表示日期,并添加 Authorization 标头:

GET https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/DOMAIN_NAME/SOURCE_USERNAME

替换以下内容:

  • DOMAIN_NAME:Google Workspace 域名,例如 example.com。
  • SOURCE_USERNAME:您要检索的电子邮件监控器的用户名。

此操作的请求正文中没有参数,因此 XML 正文为空。

检索所有电子邮件监控器的示例

此示例检索为用户 amal@example.com 创建的所有监控器:

协议

GET https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal

如果成功,服务器将返回 201 CREATED 状态代码和一个 AtomPub Feed,其中包含两个监控器的 entry 元素,显示两个目标用户 (izumi@example.com, taylor@example.com) 的设置。

<feed xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:apps='http://schemas.google.com/apps/2006'>
    <id>https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal</id>
    <updated>2010-03-17T15:29:21.064Z</updated>
    <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal'/>
    <link rel='http://schemas.google.com/g/2005#post' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal'/>
    <link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal'/>
    <openSearch:startIndex>1</openSearch:startIndex>
    <entry>
        <id>https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi</id>
        <updated>2022-04-17T15:29:21.064Z</updated>
        <link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi&'/>
        <link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/feeds/compliance/audit/mail/monitor/example.com/amal/izumi&'/>
        <apps:property name='requestId' value='53156'/>
        <apps:property name='destUserName' value='izumi'/>
        <apps:property name='beginDate' value='2022-06-15 00:00'/>
        <apps:property name='endDate' value='2022-06-30 23:20'/>
        <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='outgoingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
   </entry>
   <entry>
        <id>>https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/taylor</id>
        <updated>2022-05-17T15:29:21.064Z</updated>
        <link rel='self' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/taylor'/>
        <link rel='edit' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/taylor'/>
        <apps:property name='requestId' value='22405'/>
        <apps:property name='destUserName' value='taylor'/>
        <apps:property name='beginDate' value='2022-06-20 00:00'/>
        <apps:property name='endDate' value='2022-07-30 23:20'/>
        <apps:property name='incomingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='outgoingEmailMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='draftMonitorLevel' value='FULL_MESSAGE'/>
        <apps:property name='chatMonitorLevel' value='FULL_MESSAGE'/>
    </entry>
</feed>

Java

import com.google.gdata.client.appsforyourdomain.audit.AuditService;
import com.google.gdata.data.appsforyourdomain.generic.GenericFeed;
...

AuditService service = new AuditService("admin@example.com", "p@55w0rd", "example.com", "example.com-auditapp-v1");
GenericFeed feed = service.retrieveMonitors("amal");

.NET

using System;
using System.Collections.Generic;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("admin@example.com", "p@55w0rd");
GenericFeed<MailMonitor> monitors = service.RetrieveMailMonitors("amal");

删除电子邮件监控事件

如需删除电子邮件监控事件,请向监控事件 Feed 的删除 URI 发出 HTTP DELETE 请求,并添加 Authorization 标头:

DELETE https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/DOMAIN_NAME/SOURCE_USERNAME/DESTINATION_USERNAME

替换以下内容:

  • DOMAIN_NAME:Google Workspace 域名,例如 example.com。
  • SOURCE_USERNAME:要删除的电子邮件监控器的用户名。
  • DESTINATION_USERNAME:接收已审核电子邮件的审核员。

删除电子邮件监控事件的示例

此示例会删除为用户 amal@example.com 创建的监控器,其中 destinationUserNameizumi

协议

DELETE https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi

Java

import com.google.gdata.client.appsforyourdomain.audit.AuditService;
...

AuditService service = new AuditService("admin@example.com", "p@55w0rd", "example.com", "example.com-auditapp-v1");
service.deleteMonitor("amal", "izumi");

.NET

using System;
using Google.GData.Apps;
using Google.GData.Extensions.Apps;
...

AuditService service = new AuditService("example.com", "example.com-auditapp-v1");
service.setUserCredentials("admin@example.com", "p@55w0rd");
service.DeleteMailMonitor("amal", "izumi");