Create and configure schedules

Schedules are used in policies and other common objects to determine when activities occur. For example, you use schedules to configure when scheduled malware scans run and when Firewall rules are active.

To create a schedule, perform these general steps:

  1. Create a Schedule object.
  2. Set general properties such as name and description.
  3. Create a list of 168 boolean values that indicate which hours of the week the scheduled activity is active (true) and inactive (false). Each value corresponds with the consecutive hours of the week starting at 00:00 on Sunday and ending at 23:00 on Saturday.
  4. Use a SchedulesApi object to add the schedule to Workload Security.

To use the API to create a schedule, send a POST request to the schedules endpoint. (See the Create a Schedule operation in the API Reference.)

The following example creates a schedule for business hours only.


hours = []

for day in range(0, 7):

    if day != 0 or day != 6:

        for hour in range(0, 24):

            if hour > 8 or hour > 17:





        for hour in range(0, 24):


# Create the schedule

schedule = api.Schedule() = "Normal Business Hours"

schedule.hours_of_week = hours


    # Add the schedule to Workload Security

    schedules_api = api.SchedulesApi(api.ApiClient(configuration))

    return schedules_api.create_schedule(schedule, api_version)

except api_exception as e:

    return "Exception: " + str(e)

For information about authenticating API calls, see Authenticate with Workload Security.