Count of Assets

Get count of assets satisfying the specified filter criteria.

[POST] /rest/2.0/count/am/asset

Input ParametersInput Parameters

Parameter

Mandatory

/Optional

Data Type

Description

filter

Optional

string

Filter the events list by providing a filter in json and xml format. Make sure your filter criteria is provided in xml/json format in the request body. If you don’t provide filter parameter, it will show details of all the assets. For more information on supported operators, refer Supported Operators.

For example (json): 

{
 "filters": [
 {
 "field": "software.product",
 "operator": "CONTAINS",
 "value": "Python"
 }
 ]
}      

For example (xml):

<FilterRequest>
<filters>
<Criteria field="software.product" operator="CONTAINS">
<value>Python</value>
</Criteria>
</filters>
</FilterRequest>      

assetLastUpdated 

Optional

string

Shows records updated on or after this date with the UTC format as yyyy-MM-ddTHH:mmZ e.g. 2019-03-01T11:30Z

This date gets updated whenever any activity happens on the asset. Few examples of such activity:

- Vulnerability Management scan

- Policy Compliance scan

- Inventory collection

- Security Configuration Assessment

- CertView scan

- AssetView or CloudView connector run

- Secure Enterprise Mobility scan

- Out-of-Band Configuration Assessment

- Asset rename

- Purge of VM, PC, OCA, CertView records

- Agent manifest download

- Asset Inventory asset identification updates

lastSeenAssetId 

Optional

string

Use to get the count of assets having asset id greater than the specified last seen assetid.

If you want to get a count of assets that fall after the specific asset id, refer to the following example:

Example:

https://gateway.qg1.apps.qualys.com/rest/2.0/count/am/asset?lastSeenAssetId=6920718

Consider the scenario, wherein you have 1000 assets.

In the API call, if you enter the asset id of the 200th asset in the lastSeenAssetId parameter, the first 200 assets are skipped from the count and the count of the rest of the assets, which is 800 is shown.

Authorization

Mandatory

string

Authorization token to authenticate to the Qualys

Cloud Platform. Prepend token with "Bearer" and one space. For example - Bearer authToken

Sample - Get Count of all assets with filter criteriaSample - Get Count of all assets with filter criteria

API Request

curl -X POST -H "Accept: */*"
-H "Authorization: Bearer <JWTToken>"
-H "Content-Type: application/json" 
-i "<qualys_base_url>/rest/2.0/count/am/asset"  filter.json

Here, filter.json file is the request in JSON format.

Sample - Request body in JSON format (filter.json)

{
"filters":[
   {
     "field":"software.authorization",
     "operator":"EQUALS",
     "value":"Authorized"
   }
 ]
}      
    

Response

{
"count":850,
"responseCode":"SUCCESS",
"responseMessage":"Valid API Access"
}      
    

Sample - Added Attribute to "cloudProvider" fieldSample - Added Attribute to "cloudProvider" field

API Request

curl --location --request POST
'<qualys_base_url>/rest/2.0/count/am/asset' 
--header 'Authorization: Bearer <JWT Token>' 
--header 'Content-Type: application/xml' 
--data-raw
'<FilterRequest>'      
    

Filter

<FilterRequest>
  <filters>
    <Criteria field="alibaba.instance.instanceId" operator="EQUALS">
    <value>Instance_MN72C8</value>
    </Criteria>
  </filters>
</FilterRequest>      
    

Response

{
"count":1,
"responseCode":"SUCCESS",
"responseMessage":"Valid API Access"     
} 
    

Sample - Added hostingCategory1 informationSample - Added hostingCategory1 information

API Request

curl --location --request POST
'<qualys_base_url>/rest/2.0/count/am/asset' 
--header 'Authorization:Bearer <JWT Token>' 
--header 'Content-Type: application/xml' 
--data
'<FilterRequest>      
    

Filter

<FilterRequest>
  <filters>
     <Criteria field="asset.hostingCategory1" operator="EQUALS">
     <value>Cloud</value>
     </Criteria>
  </filters>
</FilterRequest>    
    

Response

{
"count":77,
"responseCode":"SUCCESS",
"responseMessage":"Valid API Access"
}      
    

Sample - Added Software Instance Details InformationSample - Added Software Instance Details Information

API Request

curl --location --request POST 
'<qualys_base_url>/rest/2.0/count/am/asset' 
--header 'Authorization: Bearer <JWT Token>' 
--header 'Content-Type: application/xml' 
--data-raw '<FilterRequest>' 

Filter

<FilterRequest>
 <filters>
 <criteria field="software.hasRunningInstance" operator="EQUALS">
 <value>true</value>
 </criteria>
 </filters>
</FilterRequest>    
    

Response

{
"count": 19,
"responseCode": "SUCCESS",
"responseMessage": "Valid API Access"
}      
    

Sample - Added easmTags InformationSample - Added easmTags Information

API Request

curl --location --request POST 
'<qualys_base_url>/rest/2.0/count/am/asset' 
--header 'Authorization: Bearer <JWT Token>' 
--header 'Content-Type: application/xml' 
--data '<FilterRequest>

Filter

<FilterRequest>
<filters>
<Criteria field="easm.tags.name"
operator="EQUALS"><value>cloud</value></Criteria>
</filters>
</FilterRequest>   
    

Response

{
 "count": 173,
 "responseCode": "SUCCESS",
 "responseMessage": "Valid API Access"
}      
    

Sample - Get the Count of Scanner AssetsSample - Get the Count of Scanner Assets

API Request 

curl --location
'<qualys_base_url>/rest/2.0/count/am/asset?=null' \
--header 'Content-Type: application/xml' \
--header 'Authorization: Bearer <JWT_Token>' \
--data '<FilterRequest>
<filters>
<Criteria field="asset.type" operator="EQUALS"><value>SCANNER</value></Criteria>
</filters>
</FilterRequest>'

 

API Response 

{
"count": 7,
"responseCode": "SUCCESS",
"responseMessage": "Valid API Access"
}