Add, update or delete a scan definition

Applies to:

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

Want to experience Microsoft Defender Vulnerability Management? Learn more about how you can sign up to the Microsoft Defender Vulnerability Management public preview trial.

Important

Some information relates to prereleased product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

API description

API to add, update or delete an authenticated scan.

Limitations

Rate limitations for this API are 100 calls per minute and 1500 calls per hour.

You can post on machines last seen according to your configured retention period.

Permissions

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

Permission type Permission Permission display name
Application Machine.ReadWrite.All Read and write all scan information.
Delegated (work or school account) Machine.Read.Write Read and write all scan information.

Note

When obtaining a token using user credentials:

  • To view data the user needs to have at least the following role permission: 'ViewData' or 'TvmViewData' (See Create and manage roles for more information)
  • To edit data the user needs to have at least the following role permission: 'ManageSecurity' (See Create and manage roles for more information)

HTTP request

POST https://api.securitycenter.microsoft.com/api/DeviceAuthenticatedScanDefinitions

Request headers

Name Type Description
Authorization String Bearer {token}. Required.
Content-Type string application/json. Required.

Request body

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

Parameter Type Description
ScanDefinitionIds String The scan Id. Required.

Response

If successful, this method returns 200 - Ok response code and the updated Machine in the response body.

Example request to add a new scan

Here is an example of a request that adds a new scan.

POST https://api.securitycenter.microsoft.com/api/DeviceAuthenticatedScanDefinitions
 {
"scanType": "Windows", 
"scanName": "Test Windows scan", 
"isActive": true, 
"target": "127.0.0.1", 
"intervalInHours": 1, 
"targetType": "Ip",
"scannerAgent": {
    "machineId": "eb663a27ae9d032f61bc268a79eedf14c4b90f77",
    "machineName": "DESKTOP-TEST",
"scanAuthenticationParams": { 
    "@odata.type": "#microsoft.windowsDefenderATP.api.WindowsAuthParams", 
    "type": "Kerberos", 
    "username": "username", 
    "domain": "password",
    "isGmsaUser": true
        },
    },
 },
 {
"scanType": "Network", 
"scanName": "Test Network scan", 
"isActive": true, 
"target": "127.0.0.1", 
"intervalInHours": 1, 
"targetType": "Ip",
"scannerAgent": {
    "machineId": "eb663a27678ik2f61bc268a79eeasdf450f77",
    "machineName": "DESKTOP-TEST",
"scanAuthenticationParams": {
    "@odata.type": "#microsoft.windowsDefenderATP.api.SnmpAuthParams", 
        "type": "AuthPriv", 
        "username": "username", 
        "authProtocol": "authProtocol", 
        "authPassword": "authPassword", 
        "privProtocol": "privProtocol", 
        "privPassword": "privPassword", 
        "communityString": "community-string" 
        },
    },
 }

Example request to delete scans

Here is an example of a request that deletes scans.

POST https://api.securitycenter.microsoft.com/api/DeviceAuthenticatedScanDefinitions/BatchDelete
{
  "ScanDefinitionIds": ["td32f17af-5cc2-4e4e-964a-4c4ef7d216e2", "ab32g20af-5dd2-4a5e-954a-4c4ef7d216e2"],
}

Example request to update a scan

Here is an example of a request that updates a scan.

PATCH https://api.securitycenter.microsoft.com/api/DeviceAuthenticatedScanDefinitions/a07c400a-f8e1-4329-ae66-7d3be65df0ec

{
"scanName": "Test Network scan", 
"intervalInHours": 8,
"isActive": "True",
"targetType": "Ip",
"target": "10.5.0.8",
"scanAuthenticationParams": { 
 "@odata.type": "#microsoft.windowsDefenderATP.api.SnmpAuthParams", 
    "type": "Kerberos", 
    "username": "username", 
    "domain": "password",
    "isGmsaUser": true
    }
}