List Script Jobs API

Search for the parent jobs that are created when you execute scripts.

POST /sm/v1/jobs/search

Input ParametersInput Parameters

Parameter

Mandatory/Optional

Data Type

Description

Filter

Optional

string

Filter the jobs by providing a query using Qualys syntax.

   Refer to the “How to Search” topic in the online help for

   assistance with creating your query.

   For example – “scriptId: <SCRIPT_ID>”

startAt/endAt

Optional

string

Filter jobs based on the time when the jobs are generated (dateTime) or the time when the jobs are processed at Qualys (processedTime).

pageNumber

Optional

string

The page to be returned. Starts from zero.

pageSize

Optional

string

The number of records per page to be included in the response. Default is 10.

Authorization

Mandatory

string

Authorization token to authenticate to the Qualys Enterprise TruRisk™ Platform.

Prepend the token with 'Bearer', followed by a space. For example:

Bearer <authToken>

sort

Optional

string

Sort the results using a Qualys token. For example, ID or Category:

[{\"Cre­ated.date­Time\":\"asc\"}]

SampleSample

API Request

"curl --location --request POST""https://<qualys_base_url>/sm/v1/jobs/search""\\
--header""Content-Type: application/json""\\
--header""Authorization: Bearer <authToken>""\\
--data-raw""'{
\"filter\":\"script.name:Script test for subscribed modules\"
}"

 Request Body

 i) Filter jobs using script name
{
"filter":"script.name:Script test for subscribed modules"
}

Response

 {
   "errorCode": null,
   "message": null,
   "body": {
       "totalCount": 13,
       "list": [
           {
               "severity": 2,
               "test": true,
               "created": {
                   "dateTime": 1651847969380
               },
               "executionType": "Manual",
               "correlationUuid": "9bde85fb-010e-45fe-8bc0-4b55cc6c3a2a",
               "threshold": 12,
               "title": "Script test for subscribed modules-1651847969",
               "platform": "WINDOWS",
               "updatedDateTime": 1651847969380,
               "scriptId": 72653,
               "customerUuid": "317df02c-4ad1-55e2-83a3-5646a34fceec",
               "isTest": true,
               "scriptType": "Python",
               "id": "79097",
               "category": {
                   "name": "General Automation",
                   "id": 6
               }
           }
           }
       ]
   }
}

To know the details of the response codes, refer to the Appendix.

POST /sm/v2/jobs/search

Input ParametersInput Parameters

Parameter

Mandatory/Optional

Data Type

Description

Filter

Optional

string

Filter the jobs by providing a query using Qualys syntax.

   Refer to the “How to Search” topic in the online help for

   assistance with creating your query.

   For example – “scriptId: <SCRIPT_ID>”

startAt/endAt

Optional

string

Filter jobs based on the time when the jobs are generated (dateTime) or the time when the jobs are processed at Qualys (processedTime).

pageNumber

Optional

string

The page to be returned. Starts from zero.

pageSize

Optional

string

The number of records per page to be included in the response. Default is 10.

Authorization

Mandatory

string

Authorization token to authenticate to the Qualys Enterprise TruRisk™ Platform.

Prepend the token with 'Bearer', followed by a space. For example:

Bearer <authToken>

sort

Optional

string

Sort the results using a Qualys token. For example, ID or Category:

[{\"Cre­ated.date­Time\":\"asc\"}]

 This will provide the "sortValues" field in your response body, which can be used as a cursor for pagination and could be reused in the next request body in the "searchAfter" field. 

searchAfter Optional string

To get this value, run this same API with the payload below to retrieve the "sortValues" field from the response body:

{
  "sort": "[{\"created.dateTime\": \"desc\"}, {\"id\": \"desc\"}]",
  "pageSize": 5
}

Insert the returned sortValues into the searchAfter field of your next API request. This value acts as a cursor for pagination, allowing the next call to fetch the subsequent set of records while maintaining the same sorting order.

{
    "sort": "[{\"created.dateTime\": \"desc\"}, {\"id\": \"desc\"}]",
    "searchAfter": [1774940443667, "805452" ],
    "pageSize": 5
}

 This is generally used in case if you want to fetch more than 10,000 records. 
Refer to the Pagination Support for APIs.

SampleSample

API Request

curl --location --request POST "https://qualys_base_url/sm/v2/jobs/search" \
--header "Authorization: Bearer <Bearer Token>" \
--header "Content-Type: application/json" \
--data-raw '{
    "filter": "script.name:Auto_script_22062022_074300047",
    "sort": "[{\"created.dateTime\": \"desc\"}, {\"id\": \"desc\"}]",
    "pageSize": 10
}'

 Request Body

{
    "filter": "script.name:Auto_script_22062022_074300047",    
    "sort": "[{\"created.dateTime\": \"desc\"}, {\"id\": \"desc\"}]",
    "pageSize": 5
}

Response

{
    "body": {
        "totalCount": 4633,
        "list": [
            {
                "sortValues": [1774951243679,"686754"],
                "data": {
                    "scriptLanguage": "Shell",
                    "shareScriptResultWithFim": false,
                    "executionType": "Manual",
                    "description": "Fim OS Audit Run",
                    "threshold": 0,
                    "title": "Auto_script_22062022_074300047-1774951243",
                    "platform": "LINUX",
                    "customerUuid": "93a2c1c4-5568-63be-81ff-8f8fa95aa479",
                    "rebootDelayInSeconds": 0,
                    "id": "686754",
                    "contentMasifKey": "93a2c1c4-5568-63be-81ff-8f8fa95aa479/276233/1766199677702",
                    "hasSoftwarePackage": false,
                    "severity": 3,
                    "thresholdNew": 500,
                    "runAsLoggedInUser": false,
                    "test": false,
                    "created": {
                        "dateTime": 1774951243679,
                        "user": {"name": "SYSTEM", "id": "00000000-0000-0000-0000-000000000000"}
                    },
                    "correlationUuid": "985893f0-6e95-4950-b5b3-96fc28ea1d5c",
                    "updatedDateTime": 1774951243679,
                    "rebootAfterScriptExecution": false,
                    "scriptId": 276233,
                    "isTest": false,
                    "scriptType": "Custom Script",
                    "executorAppName": "FIM",
                    "category": {"name": "System Maintenance","id": 3}
                }
            }
        ]
    }
}

For more details, refer to the Pagination Support for APIs.