Create a HTTP Cron Request

import requests

data = {
    "apiKey": "<API_KEY>",
    "name": "My Cron Request",
    "url": "https://myapi.com",
    "httpMethod": "GET",
    "recurring": True,
    "recurringCronExpression": "*/30 * * * *",
    "timezone": "America/Denver"
}

requests.post("https://api.devtabs.io/v1/createCronRequest", json=data)

Pass a JSON object to https://api.devtabs.io/v1/createCronRequest with the following fields

apiKey : String (Required)

Get the api key from the project dashboard. You can generate multiple api keys per project.

name: String (Required)

Name of the cron job. You can later use this to search on the cron dashboard.

description: String (Optional)

Optional description of the cron job. Can view the job info along with the decsiption in the dashboard.

identifiers: Dictionary (Optional)

json object where the values must be strings.

Example:

This a way to tag each job and you can search by the value in the dashboard.

One way to keep track of all jobs belonging to a particular user for example.

httpMethod: String (Required)

Must be GET, PUT, POST, DELETE, HEAD, or PATCH

url: String (Required)

a valid url. This can be the url to your api/backend service that needs to be called.

recurring: Boolean (Required)

Specify whether the cron job is recurring or not. Pass in true or false.

recurringCronExpression: String (Optional/Required)

if recurring is true then you must supply a recurringCronExpression. This can be any valid cron expression. You cannot pass the empty string ""

timezone: String (Optional/Required)

if recurring is true you must pass a timezone.

here are a list of valid timezones:

"UTC", "Europe/London", "Europe/Berlin", "Europe/Paris", "Europe/Rome", "Europe/Madrid", "Europe/Moscow", "Asia/Tokyo", "Asia/Shanghai", "Asia/Dubai", "Asia/Kolkata", "Asia/Karachi", "Asia/Jerusalem", "America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "Pacific/Honolulu", "Australia/Sydney", "Australia/Melbourne", "Pacific/Auckland", "Africa/Cairo", "Africa/Johannesburg", "America/Toronto", "America/Mexico_City", "America/Santiago", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Singapore", "Europe/Amsterdam", "Europe/Athens", "Europe/Brussels", "Europe/Budapest", "Europe/Copenhagen", "Europe/Dublin", "Europe/Helsinki", "Europe/Istanbul", "Europe/Lisbon", "Europe/Prague", "Europe/Stockholm", "Europe/Vienna", "Europe/Warsaw", "Europe/Zurich", "Pacific/Fiji"

timeToFire: Date (Optional/Required)

if recurring is false then you must supply a timeToFire. This is the time the cron job will execute and call your specified url. The date object must be in UTC.

headers: Dictionary (Optional)

Any valid json object that you want to send in the headers field.

payload: Dictionary (Optional)

Any valid json object that you want to send in the data field.

successCriteria: Dictionary (Optional)

if you leave this field blank the cron job will be considered a success if the response status code starts with a 2xx and considered failed otherwise.

If you want to determine either success of failure based on a regex you can pass in one of the following

The below object indicates that if the response from the cron execution matches the regex it will be considered a success and otherwise will be considered as failed.

{
    "successCriteria": {
        "criteria": "SUCCESS_REGEX",
        "regex": "<SOME_VALID_REGEX>"
    }
}

The below object indicates that if the response from the cron execution matches the regex it will be considered as failed and otherwise will be considered as succeeded.

"successCriteria": {
        "criteria": "FAILURE_REGEX",
        "regex": "<SOME_VALID_REGEX>",
        }

notifications: Dictionary (Optional)

Pass a dictionary containing the following attributes

notifications: {
    "notifyOnFailure": true,
    "notifyOnSuccess": false,
    "usernames": [
      "<SOME_USERNAME>" // pass in any empty array if you don't want any usernames notified 
    ],
    "groups": [
      "<SOME_GROUP_ID>" // pass in an empty array if you don't want any groups notified
    ],
    "notifyVia": [
      "EMAIL", // include one of the two 
      "MOBILE"
    ]
  }

Specify if you want to be notified on failure or success. Pass in usernames and group ids to be notified. And the mechanism you want to be notified via.

configurations: Dictionary (Optional)

Specify the number of retries and timeout

retries has to be 1, 3 or 5.

 "configurations": {
    "retries": 1,
  }

Last updated