0
(0)

 Note

If you are a US Government customer, please use the URIs listed in Microsoft Defender for Endpoint for US Government customers.

 Tip

For better performance, you can use server closer to your geo location:

  • api-us.securitycenter.microsoft.com
  • api-eu.securitycenter.microsoft.com
  • api-uk.securitycenter.microsoft.com

Limitations

  1. You can only run a query on data from the last 30 days.
  2. The results will include a maximum of 100,000 rows.
  3. The number of executions is limited per tenant:
    • API calls: Up to 45 calls per minute, up to 1500 calls per hour.
    • Execution time: 10 minutes of running time every hour and 3 hours of running time a day.
  4. The maximal execution time of a single request is 10 minutes.
  5. 429 response will represent reaching quota limit either by number of requests or by CPU. Read response body to understand what limit has been reached.
  6. The maximum query result size of a single request cannot exceed 124 MB. If exceeded, HTTP 400 Bad Request with the message “Query execution has exceeded the allowed result size. Optimize your query by limiting the amount of results and try again” will appear.

Permissions

One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Use Microsoft Defender for Endpoint APIs

PERMISSIONS
Permission type Permission Permission display name
Application AdvancedQuery.Read.All ‘Run advanced queries’
Delegated (work or school account) AdvancedQuery.Read ‘Run advanced queries’

 Note

When obtaining a token using user credentials:

  • The user needs to have ‘View Data’ AD role
  • The user needs to have access to the device, based on device group settings (See Create and manage device groups for more information)

HTTP request

HTTP

POST https://api.securitycenter.microsoft.com/api/advancedqueries/run

Request headers

REQUEST HEADERS
Header Value
Authorization Bearer {token}. Required.
Content-Type application/json

Request body

In the request body, supply a JSON object with the following parameters:

REQUEST BODY
Parameter Type Description
Query Text The query to run. Required.

Response

If successful, this method returns 200 OK, and QueryResponse object in the response body.

Example

Request example

Here is an example of the request.

HTTP

POST https://api.securitycenter.microsoft.com/api/advancedqueries/run
JSON

{
    "Query":"DeviceProcessEvents
|where InitiatingProcessFileName =~ 'powershell.exe'
|where ProcessCommandLine contains 'appdata'
|project Timestamp, FileName, InitiatingProcessFileName, DeviceId
|limit 2"
}

Response example

Here is an example of the response.

 Note

The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

JSON

{
    "Schema": [
        {
            "Name": "Timestamp",
            "Type": "DateTime"
        },
        {
            "Name": "FileName",
            "Type": "String"
        },
        {
            "Name": "InitiatingProcessFileName",
            "Type": "String"
        },
        {
            "Name": "DeviceId",
            "Type": "String"
        }
    ],
    "Results": [
        {
            "Timestamp": "2020-02-05T01:10:26.2648757Z",
            "FileName": "csc.exe",
            "InitiatingProcessFileName": "powershell.exe",
            "DeviceId": "10cbf9182d4e95660362f65cfa67c7731f62fdb3"
        },
        {
            "Timestamp": "2020-02-05T01:10:26.5614772Z",
            "FileName": "csc.exe",
            "InitiatingProcessFileName": "powershell.exe",
            "DeviceId": "10cbf9182d4e95660362f65cfa67c7731f62fdb3"
        }
    ]
}

Source : Official Microsoft Brand
Editor by : BEST Antivirus KBS Team

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

(Visited 18 times, 1 visits today)