監控電子郵件

如要使用 Email Audit API 設定電子郵件監控功能,管理員必須設定日期範圍,讓稽核人員收到特定使用者傳送和接收電子郵件的副本做為附件。每天最多可提出 1,000 次監控建立和刪除要求。這項限制適用於每個網域,且包含所有管理員在當天提出的所有要求。

監控電子郵件情境包含三種類型的使用者:

  • 管理員:任何網域管理員都可以使用 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
  • destUserNameizumi
  • beginDateJune 15, 2022, 00:00 hours
  • endDateJune 30, 2022, 23:20 hours
  • incomingEmailMonitorLevelFULL_MESSAGE
  • outgoingEmailMonitorLevelHEADER_ONLY
  • draftMonitorLevelFULL_MESSAGE
  • chatMonitorLevelFULL_MESSAGE
通訊協定Java.NET
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>
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);
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);

更新電子郵件監控器

當您使用相同的來源使用者和目的地使用者更新監控器時,初始監控器的資源設定會替換為新設定。

如要更新電子郵件監控器中的稽核設定,請將 POST 要求傳送至監控器動態饋給的 URI,並納入 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

通訊協定Java.NET
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>
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);
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 格式對監控器動態饋給 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 建立的所有監控器:

通訊協定Java.NET
GET https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal

如果成功,伺服器會傳回 201 CREATED 狀態碼,以及包含兩個螢幕的 entry 元素的 AtomPub 動態饋給,顯示兩個目的地使用者的設定 (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>
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");
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");

刪除電子郵件監控器

如要刪除電子郵件監控器,請對監控器動態饋給的刪除 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

通訊協定Java.NET
DELETE https://apps-apis.google.com/a/feeds/compliance/audit/mail/monitor/example.com/amal/izumi
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");
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");