Create HTTP schedule
curl --request POST \
--url https://scheduler.studio.lyzr.ai/http-schedules/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://api.example.com/reports/refresh",
"cron_expression": "0 9 * * 1-5",
"method": "POST",
"headers": {
"Authorization": "Bearer TARGET_TOKEN"
},
"body": {
"report": "daily"
},
"timeout_seconds": 120,
"timezone": "UTC",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh"
}
'import requests
url = "https://scheduler.studio.lyzr.ai/http-schedules/"
payload = {
"url": "https://api.example.com/reports/refresh",
"cron_expression": "0 9 * * 1-5",
"method": "POST",
"headers": { "Authorization": "Bearer TARGET_TOKEN" },
"body": { "report": "daily" },
"timeout_seconds": 120,
"timezone": "UTC",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://api.example.com/reports/refresh',
cron_expression: '0 9 * * 1-5',
method: 'POST',
headers: {Authorization: 'Bearer TARGET_TOKEN'},
body: JSON.stringify({report: 'daily'}),
timeout_seconds: 120,
timezone: 'UTC',
max_retries: 3,
retry_delay: 60,
label: 'Nightly report refresh'
})
};
fetch('https://scheduler.studio.lyzr.ai/http-schedules/', 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://scheduler.studio.lyzr.ai/http-schedules/",
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([
'url' => 'https://api.example.com/reports/refresh',
'cron_expression' => '0 9 * * 1-5',
'method' => 'POST',
'headers' => [
'Authorization' => 'Bearer TARGET_TOKEN'
],
'body' => [
'report' => 'daily'
],
'timeout_seconds' => 120,
'timezone' => 'UTC',
'max_retries' => 3,
'retry_delay' => 60,
'label' => 'Nightly report refresh'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://scheduler.studio.lyzr.ai/http-schedules/"
payload := strings.NewReader("{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://scheduler.studio.lyzr.ai/http-schedules/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scheduler.studio.lyzr.ai/http-schedules/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}"
response = http.request(request)
puts response.read_body{
"id": "66f1c4d2e4b0a1b2c3d4e5f8",
"url": "https://api.example.com/reports/refresh",
"method": "POST",
"timeout_seconds": 120,
"cron_expression": "0 2 * * *",
"timezone": "UTC",
"created_at": "2023-11-07T05:31:56Z",
"headers": {},
"body": "<unknown>",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh",
"is_active": true,
"updated_at": "2023-11-07T05:31:56Z",
"next_run_time": "2023-11-07T05:31:56Z",
"last_run_at": "2023-11-07T05:31:56Z",
"last_run_success": true,
"last_run_status": 123,
"last_attempt_count": 123
}HTTP Schedules
Create HTTP Schedule
Call any URL on a cron schedule.
POST
/
http-schedules
/
Create HTTP schedule
curl --request POST \
--url https://scheduler.studio.lyzr.ai/http-schedules/ \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://api.example.com/reports/refresh",
"cron_expression": "0 9 * * 1-5",
"method": "POST",
"headers": {
"Authorization": "Bearer TARGET_TOKEN"
},
"body": {
"report": "daily"
},
"timeout_seconds": 120,
"timezone": "UTC",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh"
}
'import requests
url = "https://scheduler.studio.lyzr.ai/http-schedules/"
payload = {
"url": "https://api.example.com/reports/refresh",
"cron_expression": "0 9 * * 1-5",
"method": "POST",
"headers": { "Authorization": "Bearer TARGET_TOKEN" },
"body": { "report": "daily" },
"timeout_seconds": 120,
"timezone": "UTC",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://api.example.com/reports/refresh',
cron_expression: '0 9 * * 1-5',
method: 'POST',
headers: {Authorization: 'Bearer TARGET_TOKEN'},
body: JSON.stringify({report: 'daily'}),
timeout_seconds: 120,
timezone: 'UTC',
max_retries: 3,
retry_delay: 60,
label: 'Nightly report refresh'
})
};
fetch('https://scheduler.studio.lyzr.ai/http-schedules/', 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://scheduler.studio.lyzr.ai/http-schedules/",
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([
'url' => 'https://api.example.com/reports/refresh',
'cron_expression' => '0 9 * * 1-5',
'method' => 'POST',
'headers' => [
'Authorization' => 'Bearer TARGET_TOKEN'
],
'body' => [
'report' => 'daily'
],
'timeout_seconds' => 120,
'timezone' => 'UTC',
'max_retries' => 3,
'retry_delay' => 60,
'label' => 'Nightly report refresh'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://scheduler.studio.lyzr.ai/http-schedules/"
payload := strings.NewReader("{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://scheduler.studio.lyzr.ai/http-schedules/")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://scheduler.studio.lyzr.ai/http-schedules/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://api.example.com/reports/refresh\",\n \"cron_expression\": \"0 9 * * 1-5\",\n \"method\": \"POST\",\n \"headers\": {\n \"Authorization\": \"Bearer TARGET_TOKEN\"\n },\n \"body\": {\n \"report\": \"daily\"\n },\n \"timeout_seconds\": 120,\n \"timezone\": \"UTC\",\n \"max_retries\": 3,\n \"retry_delay\": 60,\n \"label\": \"Nightly report refresh\"\n}"
response = http.request(request)
puts response.read_body{
"id": "66f1c4d2e4b0a1b2c3d4e5f8",
"url": "https://api.example.com/reports/refresh",
"method": "POST",
"timeout_seconds": 120,
"cron_expression": "0 2 * * *",
"timezone": "UTC",
"created_at": "2023-11-07T05:31:56Z",
"headers": {},
"body": "<unknown>",
"max_retries": 3,
"retry_delay": 60,
"label": "Nightly report refresh",
"is_active": true,
"updated_at": "2023-11-07T05:31:56Z",
"next_run_time": "2023-11-07T05:31:56Z",
"last_run_at": "2023-11-07T05:31:56Z",
"last_run_success": true,
"last_run_status": 123,
"last_attempt_count": 123
}Use an HTTP schedule to call an external API, kick off a refresh job, or hit another Lyzr endpoint on a fixed cadence. For running an agent, use Create Schedule instead.
If
body is an object or array, it is sent as JSON. Any other value is sent as a raw string. cron_expression uses standard five-field cron syntax. See Cron expressions.Authorizations
Body
application/json
Response
HTTP schedule created.