API to get Microsoft Defender Campaigns

Hashem Barakat 0 Reputation points
2025-01-06T10:36:01.8966667+00:00

Is there a way to get the Campaigns data inside the Microsoft Defender Portal using an API?
User's image

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,711 questions
Microsoft Defender for Identity
Microsoft Defender for Identity
A Microsoft service that helps protect enterprise hybrid environments from multiple types of advanced, targeted cyberattacks and insider threats.
246 questions
Microsoft Defender for Cloud Apps
Microsoft Defender for Cloud Apps
A Microsoft cloud access security broker that enables customers to control the access and use of software as a service apps in their organization.
170 questions
{count} votes

1 answer

Sort by: Most helpful
  1. DAVID BELOVED 0 Reputation points
    2025-01-28T09:30:07.04+00:00

    you can retrieve Microsoft Defender campaigns data through the Microsoft Graph Security API. This API allows you to interact programmatically with various Microsoft Defender services, including Microsoft Defender for Endpoint and Microsoft Defender for Identity, to retrieve threat-related information like campaigns, alerts, and more.

    To get campaign data specifically, you can query the SecurityAlert or SecureScore API, which provides data on active threats, alerts, and campaigns.

    Steps to get Campaign Data via Microsoft Defender API:

    1. Authenticate: Use Azure Active Directory (Azure AD) to authenticate and get an access token to interact with Microsoft Graph API.
    2. Query Campaigns Data: Use the endpoint to retrieve alerts, which can include campaigns:

    GET https://graph.microsoft.com/v1.0/security/alerts

    You can filter and expand the results based on campaign and other details. Microsoft Defender may categorize threats into campaigns, so look for a relevant field like campaignName or campaignId in the response.

    1. Microsoft Defender API Endpoints: Some relevant Microsoft Defender endpoints include:

    Microsoft Defender for Endpoint: https://graph.microsoft.com/v1.0/security/alerts

    Microsoft Defender for Identity: https://graph.microsoft.com/v1.0/security/identityProtection/riskDetections

    Microsoft Defender for Cloud Apps: https://graph.microsoft.com/v1.0/security/cloudAppSecurity

    Microsoft Defender for Cloud: https://graph.microsoft.com/v1.0/security/secureScores

    1. Data Fields: After querying these endpoints, you should examine the response to identify the campaigns. The response will contain threat or alert information, including details of campaigns, severity, affected entities, etc.

    Example of querying alerts:

    GET https://graph.microsoft.com/v1.0/security/alerts?$filter=campaignName eq 'Campaign XYZ'

    This will give you all alerts related to a specific campaign.

    Authentication Setup:

    Get Azure AD Token: Make sure to follow the process for registering an app in Azure AD and use OAuth 2.0 to obtain an access token.

    Permissions: Ensure you request the necessary permissions like SecurityEvents.Read.All or Security.Read.All for reading data related to security alerts and campaigns.

    You can find more documentation and detailed API references on Microsoft’s official Graph API DAVID BELOVED


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.