Schedule Task
Set Schedule
The set_schedule task creates a schedule on a stub. A schedule fires its triggers at the configured times, and each time a trigger fires it runs the actions defined on the schedule.
Basic usage
Parameters
schedule_name required string
The name of the schedule. There can only be one schedule on a stub with a specific name. If another schedule is set with the same name as a schedule that already exists on a stub, the newest schedule with that name will override the previous schedule.
description required string
The description of the schedule. The name and description of the schedule are shown in a comment on actions run by a schedule. Helps track the purpose of long-running schedules
remove_conditions optional array
An array of conditions, that when evaluated to true, will mark the schedule as completed. The remove conditions are evaluated before the schedule runs actions.
triggers required array
An array of trigger objects that will trigger the schedule to run actions. There are three different types of triggers: cron, once, and repeated. A trigger can only be of one type, but the trigger array can contain multiple triggers of different types.
Show child attributes
cron optional string
The cron expression for when the trigger is fired to run the schedule. Using this key will set the trigger to a cron trigger.
once optional string
A SugarTime date and time. The date and time can be relative, for example: 'in 5 hours', 'in 10 minutes'. The date and time can also be set to a specific date and time, for example: '2078-09-25 10:25' which will trigger at 10:25 on the 25th of September 2078. Using this key will set the trigger to a once schedule.
repeated optional string
A SugarTime date and time. The repeated takes the date and time in the same format as the once schedule. The only difference between a once and a repeated trigger is that a once only fires once whereas a repeated trigger can fire multiple times. The time and date for the next repeated to fire is based on the time and date that the previous repeated fired. For example: in 5 hours will fire the trigger 5 hours from the time it was created, the next repeated will then fire 5 hours after the first, etc.
timezone optional string
The timezone for the trigger. The timezone works for repeated and once triggers. The timezone format must be in the IANA timezone format e.g: America/New_York, Africa/Johannesburg, Asia/Tokyo.
expires_in optional string
A SugarTime date and time for when a trigger must expire and stop triggering the schedule. expires_in can be used for any type of trigger
run_count optional number
How many times the trigger must fire before it must stop triggering the schedule. run_count can be used with cron and repeated triggers.
actions required array
An array of actions that must be run when one of the triggers fires and activates the schedule.
Show child attributes
action_name required string
The name of the action to run.
data required object
The data to be passed to the action when it runs.
message required string
The stubpost message passed to the action when it runs.
stubref required string
The stubref where the action must be run.
bulk_action optional boolean
When true, the action will be run on the bulk queue.
Result
Properties
scheduleuuid
The scheduleuuid of the schedule to uniquely identify it.
schedule_name
The name of the schedule.
remove_conditions
The remove conditions of the schedule.
schedule_triggers
An array of the triggers of the schedule
Show child attributes
type
The type of the trigger either: cron, repeated or once
cron_expression
The cron expression of a cron trigger.
once_date
The date and time that the once trigger will fire.
repeat_date
The date and time that repeated trigger will first fire.