agents

Create a schedule

Changed on

Creates a schedule of an agent: each occurrence of cron_expression, read in time_zone, starts a run of the agent with trigger scheduled and the schedule's id, built from run_template as POST /runs builds a saved agent's run. A cron expression or time zone that doesn't parse, an expression that never fires, a revision of another agent, an agent with no revision, or a schedule with no occurrence before its end_at is 400.

post/agents/{agent_id}/schedules

Request

Path parameters

agent_idstring uuid required

The agent's id.

Request body

$schemastring uri

A URL to the JSON Schema for this object.

cron_expressionstring required

Five-field cron: minute, hour, day of month, month, day of week. For example 0 9 * * 1-5 is 09:00 on weekdays.

end_atstring date-time

No occurrence at or after this time. Leave out to run until deleted.

namestring

A label for the schedule.

overlap_policy'skip' | 'queue'

skip (default) drops an occurrence while the previous run is unfinished; queue starts it anyway.

start_atstring date-time

No occurrence before this time. Leave out to start now.

time_zonestring required

The IANA time zone cron_expression is read in, for example America/Los_Angeles or UTC.

Example request

{
  "$schema": "/api/v1/AgentScheduleCreateRequest.json"
}

Response

Created

$schemastring uri

A URL to the JSON Schema for this object.

agent_idstring uuid required

The agent the schedule runs.

created_atstring date-time required

When the schedule was created.

cron_expressionstring required

Five-field cron: minute, hour, day of month, month, day of week.

end_atstring date-time

No occurrence at or after this time. Once it passes, the schedule ends and its runs that have not started are cancelled.

idstring uuid required

The schedule's id.

last_run_idstring uuid

The run the schedule last started.

namestring required

The schedule's label.

next_run_atstring date-time

When the next occurrence starts a run, or end_at when no occurrence is left before it. Absent unless the schedule is active.

overlap_policy'skip' | 'queue' required

skip drops an occurrence while the schedule's previous run is scheduled, queued, running or paused. queue starts it anyway, waiting for a phone like any run.

start_atstring date-time

No occurrence before this time.

state'active' | 'paused' | 'ended' required

active runs its occurrences. paused runs none until resumed. ended is final: the schedule passed its end_at.

time_zonestring required

The IANA time zone cron_expression is read in, so local times hold across daylight saving.

updated_atstring date-time required

When the schedule was last changed.

Example response

{
  "$schema": "/api/v1/AgentSchedule.json"
}

Changes