Schedule Script Execution API
Create a schedule to enable script execution at a specific date and time in the future. Schedules can be of two types:
- One-time schedule
- Recurring schedule
- StartDate, EndDate, and StartTime are mandatory fields
- Recurring schedule job can be any of the following: Hourly, Daily, Weekly, Monthly
You must have a unique title for the schedule. The following error message is displayed if another schedule already exists by the same title:
“Scheduler with the same title already exists: <Schedule Title>”
Input ParametersInput Parameters
| Parameter | Mandatory/Optional | Data Type | Description |
|---|---|---|---|
| activate | String | Activate flag can be set to true if user wants to activate the schedule for execution of script. | |
| Authorization | Mandatory | String |
Authorization token to authenticate to the Qualys Enterprise TruRisk™ Platform. Prepend token with "Bearer" and one space. For example, Bearer authToken. |
| assetTags | UUID (String) , ID (Integer) |
Provide the agent UUID and the Asset Tag ID. For example: [{UUId: "0479cf1f-46a8-47ac-af52-3984e60f825b", id: 119082623}] |
|
| Assets |
Provide the agent UUID and the Asset Tag ID. For example: [{UUId: "0479cf1f-46a8-47ac-af52-3984e60f825b", id: 119082623}] |
||
| Description | String | Provide a description for the schedule | |
| excludedAssets | UUID (String), ID (Integer) |
Asset IDs on which you do not want the script to be executed. Multiple comma-separated asset IDs can be provided. For example: excludedAssets: [{UUId: "322ff7aa-cc5a-4674-8201-bfb06bbf2c1f", id: 21789601}] |
|
| Scriptid | String | The ID of the script to be scheduled for execution. | |
| Scripttitle | String | The title of the script to be executed. | |
| title | String | The title of the schedule. | |
|
user ID |
String | The customer UUID. | |
| user name | String | Customer's user name. | |
| endDate | String | Last date of the schedule. | |
| startDate | String | Date on which the schedule should start. | |
| startTime | String | Time at which the schedule should start. | |
| scheduleType | String | Recurrence type of the schedule - ONE_TIME, DAILY, HOURLY, WEEKLY. | |
| hourlyInterval | Integer | Only applicable to ’Hourly’ schedule type. Indicates that the script is to be executed with an interval of the specified number of hours. | |
| daysOfWeek | String | Applicable only for ’Weekly’ schedule type. Indicates that the script is to be executed with an interval of the specified number of days of the week. | |
| recurrenceDate | Integer | Applicable for ’Monthly’ schedule type. Denotes on which date of the month the script is to be executed. | |
| recurrenceMonth | Boolean | Applicable for ’Monthly’ schedule type. Denotes on which month of the year the script is to be executed. | |
| rebootAfterScriptEx ecution | Optional | Boolean | Provide the value as true/false based on user choice to reboot agent after script execution. |
| rebootDelayTimeUn it | Optional | String | Provide the values as second, minutes or hours. You can choose anything between 10minutes to 48 hours. |
| rebootDelayInSecon ds | Optional | Integer | Provide the time unit in seconds after which agent reboot should happen. |
API Request
"curl -X POST ‘htps"://<qualys_base_url>/sm/v1/scripts/scheduler" \\
--header ""Content-Type":"application/json"" \\
--header ""Authorization":"Bearer <AuthToken>"" \\
--data "{
"activate":true,
"assetTags":[
],
"assets":[
{
"UUId":"<Asset_UUid>",
"id":"<AssetId>"
}
],
"description":"",
"excludedAssets":[
],
"rebootAfterScriptExecution":true,
"rebootDelayInSeconds":600,
"rebootDelayTimeUnit":"<Reboot Time unit in SECONDS,MINUTES or HOURS>",
"scripts":[
{
"id":"<ScriptId>",
"title":"<ScriptTitle>"
}
],
"title":"<ScheduleTitle>",
"user":{
"id":"",
"name":""
},
"endDate":"2024-03-24",
"startDate":"2024-03-22",
"startTime":"07:55:00",
"scheduleType":"DAILY"
}"'"
Request Body: Onw-Time Schedule
{
" ""activate":true,
" ""assetTags":[
],
" ""assets":[
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>
"
}" "
],
" ""description":"",
" ""excludedAssets":[
],
" ""scripts":[
" "{
" ""id":"<SCRIPT ID>",
" ""title":"<SCRIPT TITLE>"" "
}" "
],
" ""title":"SCHEDULE TITLE",
" ""user":{
" ""id":"<USER ID>",
" ""name":"<USER NAME>"" "
},
" ""endDate":"2022-05-11",
" ""startDate":"2022-05-11",
" ""startTime":"07:25:00",
" ""scheduleType":"ONE_TIME"
}
Request Body: Recurring Monthly Schedule
{
" ""activate":true,
" ""assetTags":[
],
" ""assets":[
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>"" "
}" "
],
" ""description":"",
" ""excludedAssets":[
],
" ""scripts":[
" "{
" ""id":"<SCRIPT ID>",
" ""title":"<SCRIPT TITLE>"" "
}" "
],
" ""title":"<SCHEDULE TITLE>",
" ""user":{
" ""id":"<USER ID>",
" ""name":"<USER NAME>"" "
},
" ""endDate":"2022-12-31",
" ""startDate":"2022-05-12",
" ""startTime":"09:20:00",
" ""scheduleType":"MONTHLY",
" ""recurrenceDate":7,
" ""recurrenceMonth":1,
" ""monthlyScheduleType":"MONTHLY_DATE_OF_MONTH_JOB"
}
Request Body: Recurring Weekly Schedule
{
" ""activate":true,
" ""assetTags":[
],
" ""assets":[
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>
"
},
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>
"
}" "
],
" ""description":"",
" ""excludedAssets":[
],
" ""scripts":[
" "{
" ""id":"<SCRIPT ID>",
" ""title":"<SCRIPT TITLE>"" "
}" "
],
" ""title":"<SCHEDULE TITLE>",
" ""user":{
" ""id":"<USER ID>",
" ""name":"<USER NAME>"" "
},
" ""endDate":"2022-05-16",
" ""startDate":"2022-05-11",
" ""startTime":"10:49:00",
" ""scheduleType":"WEEKLY",
" ""daysOfWeek":[
" ""1",
" ""2"" "
]
}
Request Body: Recurring Hourly Schedule
{
" ""activate":true,
" ""assetTags":[
],
" ""assets":[
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>
"
}" "
],
" ""description":"",
" ""excludedAssets":[
],
" ""scripts":[
" "{
" ""id":"<SCRIPT ID>",
" ""title":"<SCRIPT TITLE>"" "
}" "
],
" ""title":"<SCHEDULE TITLE>",
" ""user":{
" ""id":"<USER ID>",
" ""name":"<USER NAME>"" "
},
" ""endDate":"2022-05-16",
" ""startDate":"2022-05-11",
" ""startTime":"10:49:00",
" ""scheduleType":"HOURLY",
" ""hourlyInterval":6
}
Request Body: Recurring Daily Schedule
{
" ""activate":false,
" ""assetTags":[
],
" ""assets":[
" "{
" ""UUId":"<AGENT UUID>",
" ""id":"<ASSET ID>"" "
}" "
],
" ""description":"",
" ""excludedAssets":[
],
" ""scripts":[
" "{
" ""id":"<SCRIPT ID>",
" ""title":"<SCRIPT TITLE>"" "
}" "
],
" ""title":"<SCHEDULE TITLE>",
" ""user":{
" ""id":"<USER ID>",
" ""name":"<USER NAME>"" "
},
" ""endDate":"2022-05-15",
" ""startDate":"2022-05-11",
" ""startTime":"09:42:00",
" ""scheduleType":"DAILY"
}
Request Body with Reboot Enabled
{
"activate":true,
"assetTags":[
],
"assets":[
{
"UUId":"<Asset_UUid>",
"id":"<AssetId>"
}
],
"description":"",
"excludedAssets":[
],
"rebootAfterScriptExecution":true,
"rebootDelayInSeconds":600,
"rebootDelayTimeUnit":"<Reboot Time unit in SECONDS,MINUTES or HOURS>",
"scripts":[
{
"id":"<ScriptId>",
"title":"<ScriptTitle>"
}
],
"title":"<ScheduleTitle>",
"user":{
"id":"",
"name":""
},
"endDate":"2024-03-24",
"startDate":"2024-03-22",
"startTime":"07:55:00",
"scheduleType":"DAILY"
}
Response
{
" ""errorCode":"0",
" ""message":"Script scheduler created successfully",
" ""body":{
" ""id":"<Schedule ID>"" "
}
}
To know the details of the response codes, refer to Appendix.