监控电子邮件

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

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

  • 管理员 - 任何网域管理员都可以使用 Email Audit 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 状态代码和一个具有 entry 元素的 AtomPub 条目,其中显示新的监控设置:

<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_MESSAGE,而 draftMonitorLevel 会还原为 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);

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

如需检索与源用户关联的所有监控,请使用 UTC 格式的日期向监控 Feed URI 发出 HTTP GET 请求,并添加 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");