Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Hi @Netanelstern,
Welcome to Microsoft Q&A, and thank you very much for reaching out to us.
Your questions content was initially duplicated. We deleted the duplicated part to make this clearer.
Based on your description, and in addition to the Q&A assist suggestions you’ve already received, I’d like to provide some further clarification on your questions:
Do you need to create or trigger audit activities?
Based on my research and testing, you don't. Microsoft 365 services generate audit events automatically whenever users, administrators, or the system itself performs actions.
For example, in my testing environment, if I want to audit a user’s search activity in SharePoint or Outlook, the user simply performs the search action.
Then, in Microsoft Purview >Solution > Audit, I review the corresponding audit activity that Microsoft 365 generated automatically.
The API simply gives you programmatic access to the same audit events that already appear in the Purview Audit portal.
To start receiving audit records using the Office 365 Management Activity API:
First, per Microsoft’s documentation on get started with Office 365 Management Activity API, you must ensure Unified Audit Logging is enabled. If it’s not enabled, the Management Activity API will return no audit data.
Kindly note that You need the Audit Logs role (via Exchange Online role groups) to turn auditing on or off.
To check, first, ensure you have Exchange Online PowerShell installed and ExchangeOnline module imported, then connect to Security & Compliance PowerShell through this command:
Connect-IPPSSession
Sign in to your account, then run this command below to check whether Unified Audit Logging is active for the tenant:
Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled
For more details, you can refer to the Microsoft documentation on verifying Unified Audit Logging here.
Once auditing is confirmed as enabled, the next step is registering an application in Entra ID (Azure AD). Note that this requires an Azure subscription associated with the Microsoft 365 tenant so the application can obtain the necessary permissions for the Office 365 Management Activity API, for example ActivityFeed.Read, which allow the app to retrieve audit data through the API.
For more details, including a step‑by‑step guide, you can refer to Register your application in Microsoft Entra ID section on getting started with the Office 365 Management Activity API.
After the app is registered and the required permissions are granted, you simply subscribe to the audit content types you need. From that point on, the API will begin delivering the audit events that Microsoft 365 generates automatically.
As for how you know which content types to subscribe to, it depends entirely on the kinds of audit events you want to collect. Microsoft provides five audit content types, each aligned with a specific workload:
- User logins and Azure AD directory changes >
Audit.AzureActiveDirectory - SharePoint / OneDrive file access, edits, sharing, and downloads >
Audit.SharePoint - Exchange mailbox activity (read, delete, rule changes, admin actions) >
Audit.Exchange - General Microsoft 365 workloads >
Audit.General - Data Loss Prevention policy matches >
DLP.All
I also came across an external article that also provided this mapping. Feel free to check it out here.
After you subscribe to the content type you need, you can query the API for the available content blobs, then download each one and process the audit data contained inside.
For more details, you can check this Microsoft documentation on Office 365 Management Activity API reference here.
To avoid common pitfalls or troubleshooting errors, I highly suggest you check on Microsoft Office 365 Management Activity API FAQs here for additional clarity.
Also, I'm able to find an external article that offers a simplified, step‑by‑step walkthrough from start to finish, I suggest reviewing it to see if it helps clarify things further for you.
Note: Microsoft is providing this information as a convenience to you. These sites are not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above links.
I hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.