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>”

 POST/sm/v1/scripts/scheduler

Input ParametersInput Parameters

Parameter Mandatory/ Optional Data Type Description
activate Mandatory 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 Mandatory/Optional UUID (String) , ID (Integer)

Provide the agent UUID and the Asset Tag ID. For example:

[{UUId: "0479cf1f-46a8-47ac-af52-3984e60f825b", id: 119082623}]

Provide either assets or asset tags.

Assets  Mandatory/Optional UUID (String), ID (Integer)

Provide a list of agent UUIDs and their respective Asset ID. For example:

[{UUId: "0479cf1f-46a8-47ac-af52-3984e60f825b", id: 119082623}]

Provide either assets or asset tags.

title  Mandatory String The title of the schedule.
Description  Optional String Provide a description for the schedule
excludedAssets   Optional 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  Mandatory String The ID of the script to be scheduled for execution.

user ID

 Optional String The customer UUID.
user name  Optional String Customer's user name.
endDate  Mandatory / Optional String Last date of the schedule.
startDate  Mandatory String Date on which the schedule should start.
startTime  Mandatory String Time at which the schedule should start.
scheduleType   Mandatory  String Recurrence type of the schedule - ONE_TIME, DAILY, HOURLY, WEEKLY.
hourlyInterval   Mandatory / Optional 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  Mandatory / Optional 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  Mandatory / Optional Integer Applicable for ’Monthly’ schedule type. Denotes on which date of the month the script is to be executed.
recurrenceMonth  Optional 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.
executionPolicyBypassEnabled Optional Boolean Enabling the PowerShell Bypass execution policy allows both signed and unsigned scripts to run, regardless of the execution policy configured on the asset.

Possible values: true, false

Sample: Schedule script for executionSample: Schedule script for execution

API Request

curl -X POST 
"<qualys_base_url>/sm/v1/scripts/scheduler"
--header "Content-Type: application/json"
--header "Authorization: Bearer <AuthToken>"
--data '{
    "activate": false,
    "assetTags": [],
    "assets": [
      {
        "UUId": "2dabc804-fcea-4....",
        "id": 44496319
      },
      {
        "UUId": "7bb9c14f-ccd0-49d6....",
        "id": 49526617
      }
    ],
    "description": "Sample description",
    "excludedAssets": [],
    "scripts": [
      {
        "id": 226213,
        "title": "Sample script title",
        "params": [
          {
            "key": "string",
            "value": "string"
          }
        ]
      }
    ],
    "title": "Sample title",
    "user": {
      "id": "ddf20f3a-cfd3-6fd....",
      "name": "User name"
    },
    "allTagsForAssetsEnabled": false,
    "rebootAfterScriptExecution": false,
    "rebootDelayInSeconds": null,
    "rebootDelayTimeUnit": null,
    "endDate": null,
    "startDate": "2025-05-21",
    "startTime": "07:23:00",
    "scheduleType": "ONE_TIME",
    "executionPolicyBypassEnabled": true,
    "shareScriptResultWithFim": true
}'

 Request Body: One-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"
}

API Response

{
  "errorCode": "0",
  "message": "Script scheduler created successfully",
  "body": {
    "id": "<Schedule ID>"
  }
}

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