Update a schedule
curl --request PATCH \
--url https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": {},
"timing": {},
"session_request": {}
}
'import requests
url = "https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}"
payload = {
"name": "<string>",
"description": {},
"timing": {},
"session_request": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: {}, timing: {}, session_request: {}})
};
fetch('https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}', 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://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => [
],
'timing' => [
],
'session_request' => [
]
]),
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://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}"
response = http.request(request)
puts response.read_bodySchedules
Update a schedule
Change a schedule’s name, timing, or session template.
PATCH
/
api
/
v2
/
schedules
/
{schedule_id}
Update a schedule
curl --request PATCH \
--url https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": {},
"timing": {},
"session_request": {}
}
'import requests
url = "https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}"
payload = {
"name": "<string>",
"description": {},
"timing": {},
"session_request": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: {}, timing: {}, session_request: {}})
};
fetch('https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}', 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://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => [
],
'timing' => [
],
'session_request' => [
]
]),
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://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://agp.eu.hcompany.ai/api/v2/schedules/{schedule_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": {},\n \"timing\": {},\n \"session_request\": {}\n}"
response = http.request(request)
puts response.read_bodyPartial update: only the fields you provide change. Changing
timing recomputes the next fire from now.
Returns the updated schedule object.
Path parameters
The schedule’s id (UUID).
Request body
New display name. May not be
null.New description. Pass
null to clear it.New cron timing (same shape and constraints as Create). May not be
null. The next fire is recomputed from now.New session template (same shape and restrictions as Create). May not be
null.Examples
curl -X PATCH "https://agp.eu.hcompany.ai/api/v2/schedules/9f8e7d6c-5b4a-4c3d-8e2f-1a0b9c8d7e6f" \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timing": {"expression": "30 8 * * 1-5", "timezone": "Europe/Paris"}}'
from hai_agents import Client
client = Client()
schedule = client.schedules.update_schedule(
"9f8e7d6c-5b4a-4c3d-8e2f-1a0b9c8d7e6f",
timing={"expression": "30 8 * * 1-5", "timezone": "Europe/Paris"},
)
print(schedule.next_run_times[0])
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const schedule = await client.schedules.updateSchedule({
scheduleId: "9f8e7d6c-5b4a-4c3d-8e2f-1a0b9c8d7e6f",
timing: { expression: "30 8 * * 1-5", timezone: "Europe/Paris" },
});
console.log(schedule.nextRunTimes[0]);
Errors
| Status | Cause |
|---|---|
400 | The new expression fires more often than once every 5 minutes, or the new template is invalid (no messages, or parent_session_id set). |
404 | No schedule with this id in your organization. |
422 | Body failed validation: invalid cron expression, unknown timezone, or explicit null for name, timing, or session_request. |
Was this page helpful?
⌘I