Get file statistics API

Applies to:

Want to experience Microsoft Defender for Endpoint? Sign up for a free trial.

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:

  • us.api.security.microsoft.com
  • eu.api.security.microsoft.com
  • uk.api.security.microsoft.com
  • au.api.security.microsoft.com
  • swa.api.security.microsoft.com
  • ina.api.security.microsoft.com

API description

Retrieves the statistics for the given file.

Limitations

  1. Rate limitations for this API are 100 calls per minute and 1500 calls per hour.
  2. The maximum value for lookbackhours is 720 Hours(30 days).

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

Permission type Permission Permission display name
Application File.Read.All 'Read file profiles'
Delegated (work or school account) File.Read.All 'Read file profiles'

Note

When obtaining a token using user credentials:

  • The user needs to have at least the following role permission: 'View Data' (For more information, see Create and manage roles)

HTTP request

GET /api/files/{id}/stats

Request headers

Name Type Description
Authorization String Bearer {token}. Required.

Request URI parameters

Name Type Description
lookBackHours Int32 Defines the hours we search back to get the statistics. Defaults to 30 days. Optional.

Request body

Empty

Response

If successful and file exists - 200 OK with statistical data in the body. If file does not exist - 404 Not Found.

Example

Request example

Here's an example of the request.

GET https://api.security.microsoft.com/api/files/0991a395da64e1c5fbe8732ed11e6be064081d9f/stats?lookBackHours=48

Response example

Here's an example of the response.

{
    "@odata.context": "https://api.security.microsoft.com/api/$metadata#microsoft.windowsDefenderATP.api.InOrgFileStats",
    "sha1": "0991a395da64e1c5fbe8732ed11e6be064081d9f",
    "organizationPrevalence": 14850,
    "orgFirstSeen": "2019-12-07T13:44:16Z",
    "orgLastSeen": "2020-01-06T13:39:36Z",
    "globallyPrevalence": 705012,
    "globalFirstObserved": "2015-03-19T12:20:07.3432441Z",
    "globalLastObserved": "2020-01-06T13:39:36Z",
    "topFileNames": [
        "MREC.exe"
    ]
}

Tip

Do you want to learn more? Engage with the Microsoft Security community in our Tech Community: Microsoft Defender for Endpoint Tech Community.