Schedule

A Schedule is an object that allows the user to execute Scans, Tests, or generate Reports at specified intervals. A Schedule can be associated with a single Site or Page and is comprised of multiple object id's and datetime & frequency specifications which are required to service the users scheduled task.

TIP

If a Schedule is created at the Site level, the associated task will run for all child Pages.

Schedule object


{
    "id":"aa6f5ba7-e83a-4ce0-a790-9a6706ed1482",        // uuid specific to Schedule
    "site":"46053956-761b-4ca6-8cec-3be796695d12",      // uuid specific to Site if not using Page
    "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",      // uuid specific to Page if not using Site
    "time_created":"2021-11-19T19:33:33.912725Z",       // timestamp of Schedule creation
    "user":"example@gmail.com",                         // user denoted by email
    "task_type":"scan",                                 // one of "scan", "test", or "report"
    "timezone":"UTC",                                   // any of the accepted timezone strings --> https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
    "begin_date":"2021-11-19T19:33:33.893999Z",         // date to begin task. Format as "mm/dd/yyyy"
    "time":"03:00",                                     // time to begin task. Format in 24hr notation (e.g. 3:00 AM becomes "03:00") 
    "frequency":"weekly",                               // how often to run the task (either "daily", "weekly", or "monthly")
    "task":"api.tasks.create_scan_bg",                  // generated automatically via Schedule API
    "crontab_id":"34",                                  // generated automatically via Schedule API
    "periodic_task_id":"10",                            // generated automatically via Schedule API
    "status":"Active",                                  // Either "Active" or "Paused"
    "automation":null,                                  // uuid specific to associated Automation if user creates and automation.
    "extras": {                                         // object containing extra data needed by background tasks 
        "configs": {                                    // scan configs
            "driver": "selenium",
            "device": "desktop",
            "mask_ids": "example-id-1, example-id-2",   // element id's you wish to mask when taking a screenshot (seperated by comma)
            "interval": 5,
            "window_size": "1920,1080", 
            "max_wait_time": 60, 
            "min_wait_time": 10,
            "disable_animations": false,                // bool which, when true, will disable all animations and videos on the site during a Scan
            "timeout": 300                              // maximum time (seconds) the driver will run before completely timing out during an the VRT process
        },
        "test_type": [],                                // test type array
        "scan_type": []                                 // scan type array
    },
}
      

Create or Update Schedule

There are two use cases for this endpoint, Creating and Updating Schedules.

POST - /schedule

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{SCANERR_API_BASE_URL}/schedule'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}
data = {
    "begin_date": "MM/DD/YYYY",
    "frequency": "daily",
    "schedule_id": "",       # Insert <schedule:id> if updating schedule
    "site_id": "<site:id>",
    "task_type": "scan",
    "time": "00:00",
    "timezone": "UTC",
    "configs": {
        "driver": "selenium",
        "device": "desktop",
        "mask_ids": "example-id-1, example-id-2",
        "interval": 5,
        "window_size": "1920,1080", 
        "max_wait_time": 60, 
        "min_wait_time": 10,
        "disable_animations": False, 
        "timeout": 300
    },
    "test_type": None,  # only if scheduled task is a Test
    "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"], # collecting all data types available 
}

# send the request
res = requests.post(
    url=url,
    headers=headers,
    data=json.dumps(data)
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:


{
   "id":"e10846cc-a8d2-442a-a79a-fe62f1479b16",
   "site":"188b882a-f644-4304-b2b9-def9d8c76b57",
   "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",
   "time_created":"2021-11-22T20:07:22.196252Z",
   "user":"example@gmail.com",
   "task_type":"scan",
   "timezone":"UTC",
   "begin_date":"2021-11-22T20:07:22.179606Z",
   "time":"00:00",
   "frequency":"daily",
   "task":"api.tasks.create_scan_bg",
   "crontab_id":"7",
   "periodic_task_id":"11",
   "status":"Active",
   "automation":null,
   "extras": { 
        "configs": { 
            "driver": "selenium",
            "device": "desktop",
            "mask_ids": "example-id-1, example-id-2",
            "interval": 5,
            "window_size": "1920,1080", 
            "max_wait_time": 60, 
            "min_wait_time": 10,
            "disable_animations": false,  
            "timeout": 300
        },
        "test_type": [],
        "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"]
    },
}

Retrieve a Schedule

This endpoint returns a single Schedule object and is useful as a simple "detailed view" of the schedule.

GET - /schedule/<schedule:id>

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/schedule/<schedule:id>'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.get(
    url=url, 
    headers=headers, 
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

{
   "id":"e10846cc-a8d2-442a-a79a-fe62f1479b16",
   "site":"188b882a-f644-4304-b2b9-def9d8c76b57",
   "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",
   "time_created":"2021-11-22T20:07:22.196252Z",
   "user":"example@gmail.com",
   "task_type":"scan",
   "timezone":"UTC",
   "begin_date":"2021-11-22T20:07:22.179606Z",
   "time":"00:00",
   "frequency":"daily",
   "task":"api.tasks.create_scan_bg",
   "crontab_id":"7",
   "periodic_task_id":"11",
   "status":"Active",
   "automation":null,
   "extras": { 
        "configs": { 
            "driver": "selenium",
            "device": "desktop",
            "mask_ids": "example-id-1, example-id-2",
            "interval": 5,
            "window_size": "1920,1080", 
            "max_wait_time": 60, 
            "min_wait_time": 10,
            "disable_animations": false, 
            "timeout": 300
        },
        "test_type": [],
        "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"], 
    },
}

Retrieve many Schedules

This endpoint returns a paginated response with all Schedule objects filtered by your account and ordered by time_created. This endpoint is useful when needing to displaying your schedules in a table view for example. The limit parameter specifies the total number of objects you want returned per "group" (we recomend keeping this under 10 for best performance). The offset parameter specfies which "group" to return. For example, limit=10&offset=10 in a total dataset of 30 objects would return 10 schedules in range schedule #10 - schedule #20.

TIP

Additionally, optional parameters are site_id=<site:id> which would limit the objects filtering to the associated Site and page_id=<page:id> which would limit the objects filtering to the associated Page.

GET - /schedule?limit=10&offset=0

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/schedule?limit=10&offset=0'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.get(
    url=url, 
    headers=headers, 
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

{
   "count":30,
   "next":"https://api.scanerr.io/v1/ops/schedule?limit=10&offset=20",
   "previous":"https://api.scanerr.io/v1/ops/schedule?limit=10&offset=10",
   "results":[
        {
            "id":"e10846cc-a8d5-442a-a79a-fe62f1473b16",
            "site":"188b882a-f644-4204-b2b9-def9c8c76b57",
            "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",
            "time_created":"2021-10-22T20:05:22.1964322Z",
            "user":"example@gmail.com",
            "task_type":"scan",
            "timezone":"UTC",
            "begin_date":"2021-11-22T20:07:22.179606Z",
            "time":"00:00",
            "frequency":"weekly",
            "task":"api.scan.create_scan_bg",
            "crontab_id":"4",
            "periodic_task_id":"11",
            "status":"Active",
            "automation":null,
            "extras": { 
                "configs": { 
                    "driver": "selenium",
                    "device": "desktop",
                    "mask_ids": "example-id-1, example-id-2",
                    "interval": 5,
                    "window_size": "1920,1080", 
                    "max_wait_time": 60, 
                    "min_wait_time": 10,
                    "disable_animations": false,
                    "timeout": 300
                },
                "test_type": [],
                "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"],
            },
            
        },
        {
            "id":"e10846cc-a8d2-442a-a79a-fe62f1479b16",
            "site":"188b882a-f644-4304-b2b9-def9d8c76b57",
            "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",
            "time_created":"2021-11-22T20:07:22.196252Z",
            "user":"example@gmail.com",
            "task_type":"scan",
            "timezone":"UTC",
            "begin_date":"2021-11-22T20:07:22.179606Z",
            "time":"00:00",
            "frequency":"daily",
            "task":"api.tasks.create_scan_bg",
            "crontab_id":"7",
            "periodic_task_id":"11",
            "status":"Active",
            "automation":null,
            "extras": { 
                "configs": {
                    "driver": "selenium",
                    "device": "desktop", 
                    "mask_ids": "example-id-1, example-id-2",
                    "interval": 5,
                    "window_size": "1920,1080", 
                    "max_wait_time": 60, 
                    "min_wait_time": 10
                    "disable_animations": false,
                    "timeout": 300
                },
                "test_type": [],
                "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"],
            },
        },
        {
            "id":"188b882a-f644-4304-b2b9-def9d8c76b57",
            "site":"e10846cc-a8d2-442a-a79a-fe62f1479b16",
            "page":"53946056-4ca6-761b-82xc-3bm9918dbd12",
            "time_created":"2021-11-14T20:04:23.1938252Z",
            "user":"example@gmail.com",
            "task_type":"test",
            "timezone":"UTC",
            "begin_date":"2021-11-22T20:07:22.179606Z",
            "time":"01:00",
            "frequency":"monthly",
            "task":"api.tasks.create_scan_bg",
            "crontab_id":"7",
            "periodic_task_id":"10",
            "status":"Paused",
            "automation":null,
            "extras": { 
                "configs": {
                    "driver": "selenium",
                    "device": "desktop", 
                    "mask_ids": "example-id-1, example-id-2",
                    "interval": 5,
                    "window_size": "1920,1080", 
                    "max_wait_time": 60, 
                    "min_wait_time": 10
                },
                "test_type": [],
                "scan_type": ["html", "logs", "lighthouse", "yellowlab", "vrt"],
            },
        },
      ### SHORTENED FOR DISPLAY PURPOSES ###
   ]
}

Delete a Schedule

Because Schedules are high-level objects within the Scanerr API, once a Schedule is deleted a cascade effect ensues and all assocaited Automations and periodic_tasks are subsequently deleted.

DANGER

Please use caution with this endpoint as it is irreversible.

DELETE - /schedule/<schedule:id>

import requests, os

# import env vars
SCANERR_API_BASE_URL = os.environ.get('SCANERR_API_BASE_URL')
SCANERR_API_TOKEN = os.environ.get('SCANERR_API_BASE_URL')

# setup configs
url = f'{BASE_URL}/schedule/<schedule:id>'
headers = {
    "content-type": "application/json",
    "Authorization" : SCANERR_API_TOKEN
}

# send the request
res = requests.delete(
    url=url, 
    headers=headers, 
)

# retrieve response data
json_response = res.json()
print(json_response)

View Full Output

Output:

    {
        "message": "schedule deleted successfully"
    }

Last Updated:
Contributors: landon