監控電子郵件

如要使用 Email Audit API 設定電子郵件監控,管理員可設定日期範圍,將特定使用者寄出及接收的電子郵件副本以附件形式接收。每日監控作業建立與刪除要求數量上限為 1,000 個要求。此限制是以網域為單位,且包含當天任何管理員在一天內提出的所有要求。

我們會監控電子郵件的情況,其中包含三種使用者類型:

  • 管理員:任何網域管理員都可以使用 Email Audit API 的監控資源,建立、擷取、更新及刪除電子郵件監控器。此外,管理員可以使用 API 下載信箱。這些作業只能在管理員運動的網域中執行。

  • 來源使用者:來源使用者是接收或傳送由監控目的地使用者稽核的訊息。任何網域管理員或帳戶使用者都可以是來源使用者。來源使用者必須與管理員和目標使用者位於相同的網域。

  • 目標使用者 — 目標使用者是收到稽核電子郵件的稽核者。

    • 接收所有傳入和傳出電子郵件的盲碳副本 (密件副本),包括傳入和傳出附件、轉寄的郵件以及從行動裝置傳送的電子郵件。
    • 網域管理員也可以選擇為目標使用者啟用額外的稽核功能。選用功能包括對已儲存電子郵件草稿的稽核、稽核封存的 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

通訊協定

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);

更新電子郵件監控器

使用相同的來源使用者和目標使用者更新監控器時,新設定會取代初始監控器的屬性設定。

如要更新電子郵件監控器中的稽核設定,請將 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_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);

擷取來源使用者的所有電子郵件監控器

如要擷取與來源使用者相關聯的所有監控器,請使用世界標準時間格式,向監控動態饋給 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 動態饋給,其中包含兩個監控器的 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");

刪除電子郵件監控器

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

通訊協定

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");