Test a cron expression
Returns the next check-in window for the cron expression. An invalid expression, timezone or timestamp still returns 200 with error set and no window.
curl --request POST \
--url https://appsignal.com/api/v2/check_ins/test_cron \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cron": "0 6 * * *",
"wait_time_minutes": 5,
"timestamp": 1614556800,
"timezone": "Europe/Amsterdam"
}
'import requests
url = "https://appsignal.com/api/v2/check_ins/test_cron"
payload = {
"cron": "0 6 * * *",
"wait_time_minutes": 5,
"timestamp": 1614556800,
"timezone": "Europe/Amsterdam"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cron: '0 6 * * *',
wait_time_minutes: 5,
timestamp: 1614556800,
timezone: 'Europe/Amsterdam'
})
};
fetch('https://appsignal.com/api/v2/check_ins/test_cron', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://appsignal.com/api/v2/check_ins/test_cron",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cron' => '0 6 * * *',
'wait_time_minutes' => 5,
'timestamp' => 1614556800,
'timezone' => 'Europe/Amsterdam'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://appsignal.com/api/v2/check_ins/test_cron"
payload := strings.NewReader("{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://appsignal.com/api/v2/check_ins/test_cron")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/check_ins/test_cron")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}"
response = http.request(request)
puts response.read_body{
"now": "2021-03-01T00:00:00Z",
"next_start": null,
"next_end": null,
"error": "Invalid cron error: Invalid pattern: ..."
}Authorizations
Authorization: Bearer <token>
Body
Request body for testing a cron schedule expression.
Cron expression to test (e.g. "0 * * * *").
Wait time in minutes for the check-in window.
Unix timestamp in seconds to evaluate against. Defaults to the current time.
IANA timezone for cron evaluation (e.g. "Europe/Amsterdam"). An empty string means UTC.
Response
The next window, or an error message when the input is invalid.
Result of evaluating a cron schedule expression.
The time evaluated against: timestamp, or the current time when omitted or out of range.
Next scheduled start time; null when error is set.
Next scheduled end time (start + wait time); null when error is set.
Why no window could be computed (invalid expression, timezone or timestamp); null on success.
Was this page helpful?
curl --request POST \
--url https://appsignal.com/api/v2/check_ins/test_cron \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cron": "0 6 * * *",
"wait_time_minutes": 5,
"timestamp": 1614556800,
"timezone": "Europe/Amsterdam"
}
'import requests
url = "https://appsignal.com/api/v2/check_ins/test_cron"
payload = {
"cron": "0 6 * * *",
"wait_time_minutes": 5,
"timestamp": 1614556800,
"timezone": "Europe/Amsterdam"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
cron: '0 6 * * *',
wait_time_minutes: 5,
timestamp: 1614556800,
timezone: 'Europe/Amsterdam'
})
};
fetch('https://appsignal.com/api/v2/check_ins/test_cron', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://appsignal.com/api/v2/check_ins/test_cron",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cron' => '0 6 * * *',
'wait_time_minutes' => 5,
'timestamp' => 1614556800,
'timezone' => 'Europe/Amsterdam'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://appsignal.com/api/v2/check_ins/test_cron"
payload := strings.NewReader("{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://appsignal.com/api/v2/check_ins/test_cron")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://appsignal.com/api/v2/check_ins/test_cron")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cron\": \"0 6 * * *\",\n \"wait_time_minutes\": 5,\n \"timestamp\": 1614556800,\n \"timezone\": \"Europe/Amsterdam\"\n}"
response = http.request(request)
puts response.read_body{
"now": "2021-03-01T00:00:00Z",
"next_start": null,
"next_end": null,
"error": "Invalid cron error: Invalid pattern: ..."
}