如要使用 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。 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);
更新電子郵件監控器
使用相同來源使用者和目的地使用者更新監控器時,初始監控器的屬性設定會替換為新設定。
如要更新電子郵件監控器的稽核設定,請向監控器動態饋給的 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。本範例使用下列參數:
- 新的
endDate為August 30, 2022, 23:20 hours。 chatMonitorLevel現已更名為HEADER_ONLY。- 要稽核的使用者仍為
amal@example.com。 destUserName維持izumi。
未更新的螢幕屬性會還原為預設值。舉例來說,在這個範例中,incomingEmailMonitorLevel 和 outgoingEmailMonitorLevel 屬性會還原為 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 狀態碼和 AtomPub 項目,其中包含更新後的 entry 元素。未更新且顯示在回應中的屬性會還原為預設值。
<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 格式的日期,對監控器動態饋給 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.com 建立的監控器,並將 destinationUserName 設為 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");