logo
search
Compliance Problems

How to Enable Microsoft 365 Auditing and Collect Teams Logs via API

Nimra MalikNimra Malik Oct 19, 2026 868 views

Question details

The user wants to learn how to enable auditing in Microsoft 365 and use an API to programmatically collect Microsoft Teams audit logs, considering Office 365 E3 and E5 licensing differences.

How to Enable Microsoft 365 Auditing and Collect Teams Audit Logs Using an API
Product
Microsoft 365
Device & OS
not provided
Scenario
Setting up enterprise compliance and audit logging for Microsoft Teams via API integration.
Observed behavior
The user needs a clear process to register the application, grant permissions, request tokens, and retrieve the audit logs successfully based on their subscription tier.
Before you start

Ensure you have global administrator or compliance administrator permissions in your Microsoft 365 tenant, and access to the Microsoft Entra ID (formerly Azure AD) portal to register the application.

Solution 1Recommended

Setup Office 365 Management Activity API for Teams Logs

A complete workflow to turn on auditing, configure API access in Azure AD, and retrieve Teams audit logs.

Microsoft 365 provides the Office 365 Management Activity API to query audit events. Your licensing dictates bandwidth: E3 includes Audit (Standard) while E5 provides Audit (Premium) with higher-bandwidth access.

1
Turn on auditing

Navigate to the Microsoft Purview compliance portal, go to Audit, and click 'Start recording user and admin activity' to enable audit logging for your tenant.

2
Register your application

Go to the Microsoft Entra ID (Azure AD) admin center, select App registrations, and create a new application for your API integration.

3
Grant admin consent

In your registered app's settings, assign the necessary Office 365 Management APIs permissions and click 'Grant admin consent' for your organization.

4
Request access tokens

Configure your application code to request OAuth 2.0 access tokens from Azure AD using your tenant ID, client ID, and client secret.

5
Retrieve logs

Use the obtained access token to make HTTP GET requests to the Office 365 Management Activity API endpoints to subscribe to and query Microsoft Teams audit logs.

Setup Office 365 Management Activity API for Teams Logs
Licensing Requirements: Office 365 E3 includes Standard auditing capabilities. Upgrading to Office 365 E5 unlocks Premium auditing, which provides high-bandwidth access to the API and longer data retention.
Free Microsoft Office alternative

Discover WPS Office for Your Daily Productivity Needs

While Microsoft 365 handles complex enterprise compliance and API auditing, individual users and small businesses looking for a lightweight, highly compatible office suite can rely on WPS Office. It provides powerful Word, Excel, and PowerPoint alternatives without the heavy enterprise overhead.

Seamless compatibility with Microsoft Office file formats (.docx, .xlsx, .pptx).Lightweight software architecture that runs smoothly on older hardware.Free to use with a familiar, easy-to-navigate user interface.Built-in PDF editing and conversion tools to simplify document workflows.
microsoft office alternative - wps office

Frequently Asked Questions

What is the difference between Audit Standard and Audit Premium?

Audit (Standard) is included with Office 365 E3 and retains logs for up to 180 days. Audit (Premium) requires an Office 365 E5 license, provides up to one year of retention by default, and allows high-bandwidth access to the Management Activity API.

Why am I not seeing Teams logs immediately after enabling auditing?

After you turn on auditing in the Microsoft Purview portal, it can take up to 24 hours for audit records to begin appearing in the search results and via the API.

Can I access the Office 365 Management Activity API without an Azure AD app?

No, you must register an application in Azure AD (Microsoft Entra ID) to obtain the necessary client credentials and access tokens required to authenticate API requests.

How do I grant tenant admin consent for the API application?

In the Azure portal, navigate to your App registration's 'API permissions' page, click on 'Add a permission', select Office 365 Management APIs, configure the required access levels, and then click the 'Grant admin consent for [Your Tenant]' button.