Schedules
Update a schedule
Update a schedule’s name, timing, or session template.
PATCH
/
api
/
v2
/
schedules
/
{schedule_id}
from hai_agents import Client
client = Client()
schedule = client.schedules.update_schedule(
schedule_id,
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,
timing: { expression: "30 8 * * 1-5", timezone: "Europe/Paris" },
});
console.log(schedule.nextRunTimes[0]);
curl -X PATCH "https://agp.eu.hcompany.ai/api/v2/schedules/$SCHEDULE_ID" \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timing": {"expression": "30 8 * * 1-5", "timezone": "Europe/Paris"}}'
Behavior
Only the fields you send change. Changingtiming recomputes the next fire from now.
Path parameters
string
required
The schedule’s ID (UUID).
Request body
string
New display name, 1 to 255 characters. May not be
null.string | null
New description, up to 255 characters. Pass
null to clear it.object
New cron timing (same shape and constraints as Create). May not be
null. The next fire is recomputed from now.integer | null
How many sessions to create before the schedule becomes inactive (same meaning as Create). Pass
null to clear the limit. Setting it to a value the schedule has already reached pauses the schedule, but raising it does not resume a paused schedule.Response
200 with the updated schedule object.
from hai_agents import Client
client = Client()
schedule = client.schedules.update_schedule(
schedule_id,
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,
timing: { expression: "30 8 * * 1-5", timezone: "Europe/Paris" },
});
console.log(schedule.nextRunTimes[0]);
curl -X PATCH "https://agp.eu.hcompany.ai/api/v2/schedules/$SCHEDULE_ID" \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timing": {"expression": "30 8 * * 1-5", "timezone": "Europe/Paris"}}'
Errors
| Status | Cause |
|---|---|
400 | The new expression fires more often than once every 5 minutes, or the new template is invalid (no messages, parent_session_id set, or files attached). |
404 | Not found, or not 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
from hai_agents import Client
client = Client()
schedule = client.schedules.update_schedule(
schedule_id,
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,
timing: { expression: "30 8 * * 1-5", timezone: "Europe/Paris" },
});
console.log(schedule.nextRunTimes[0]);
curl -X PATCH "https://agp.eu.hcompany.ai/api/v2/schedules/$SCHEDULE_ID" \
-H "Authorization: Bearer $HAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"timing": {"expression": "30 8 * * 1-5", "timezone": "Europe/Paris"}}'