Run advanced hunting queries via the Microsoft Defender for Endpoint API

domain: learn.microsoft.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Register an Entra ID application, grant it WindowsDefenderATP > AdvancedQuery.Read.All application permission, and obtain a client-credentials bearer token for the audience https://api.securitycenter.microsoft.com.
  2. Submit a Kusto Query Language (KQL) query with POST https://api.securitycenter.microsoft.com/api/advancedqueries/run, with body {"Query": "YOUR_KQL_QUERY"} and Authorization: Bearer YOUR_TOKEN.
  3. Parse the JSON response; results are returned in the Results array (up to 100,000 rows) with schema defined by the columns returned from the query — no separate schema endpoint is needed.
  4. Respect API quotas: up to 45 calls per minute and 1,500 calls per hour per tenant; queries are limited to data from the last 30 days and have a maximum execution time of 200 seconds.
  5. For broader table coverage (including Microsoft Sentinel and Defender XDR tables), use the Microsoft Graph security API advanced hunting endpoint at https://graph.microsoft.com/v1.0/security/runHuntingQuery instead, which is the recommended current approach.

Known gotchas

Related routes

Retrieve Microsoft Defender for Cloud secure score and control-level compliance via the REST API
learn.microsoft.com · 5 steps · unrated
Read and update Bullhorn Candidate, JobOrder, and Placement entities using the correct search vs query endpoint
bullhorn.com · 5 steps · unrated
Query CrowdStrike Falcon API for endpoint detections
falcon.crowdstrike.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans