Incidents.OnCallRotation
A Better Stack on-call rotation: puts the users of an
OnCallSchedule on call in turns, with shifts of rotationLength
rotationIntervals (hours, days or weeks) starting at
startRotationsAt, optionally only inside weekly workingHours.
A schedule has exactly one rotation, living at the schedule’s address, so
the rotation is identified by scheduleId. Create and update are the same
replacing request: any change re-sends the whole rotation and replaces the
schedule’s future shifts (from applyFrom when given, otherwise from
startRotationsAt or now); overrides stay. Changing scheduleId or
teamId replaces the rotation (the old schedule’s rotation is removed).
Deleting it clears the shifts from today on; past shifts and overrides
stay. applyFrom and applyFromTimezone are never returned by the API:
they are compared against the previous deploy’s props. endRotationsAt,
timezone and workingHours keep their last value when removed from the
config (the API keeps them).
users are e-mail addresses of responders in the schedule’s team; putting
someone in a rotation makes them reachable by every escalation policy that
pages the schedule.
A weekly rotation
Section titled “A weekly rotation”Two people, a week each, handing over on Monday morning
const schedule = yield* BetterStack.Incidents.OnCallSchedule("primary", { name: "Primary on-call",});yield* BetterStack.Incidents.OnCallRotation("primary-rotation", { scheduleId: schedule.id, users: ["alice@example.com", "bob@example.com"], rotationLength: 1, rotationInterval: "week", startRotationsAt: "2030-01-07T09:00:00Z",});Business hours only
Section titled “Business hours only”Daily shifts that page only on weekdays from 9 to 17
yield* BetterStack.Incidents.OnCallRotation("support-rotation", { scheduleId: schedule.id, users: ["carol@example.com", "dave@example.com"], rotationLength: 1, rotationInterval: "day", startRotationsAt: "2030-01-07T09:00:00Z", timezone: "Europe/Prague", workingHours: [ { day: "monday", startTime: "09:00", endTime: "17:00" }, { day: "tuesday", startTime: "09:00", endTime: "17:00" }, { day: "wednesday", startTime: "09:00", endTime: "17:00" }, { day: "thursday", startTime: "09:00", endTime: "17:00" }, { day: "friday", startTime: "09:00", endTime: "17:00" }, ],});rotationInterval "hour" | "day" | "week" | string required
Unit for rotation_length.
rotationLength number required
How long each shift lasts, in rotation_interval units. A whole number of at least 1.
scheduleId string required
The on-call schedule the rotation belongs to (its id), or default for the team's default schedule. A schedule has one rotation; changing it replaces the rotation.
startRotationsAt string required
When the rotation schedule starts.
users string[] required
E-mail addresses of users in the rotation, in shift order. Each must be a responder in the schedule's team.
applyFrom string
The date the change applies from. Shifts before it stay as they are. Leave it out to apply the change now.
applyFromTimezone string
Time zone for apply_from. Ignored when apply_from has a UTC offset.
endRotationsAt string
When the rotation schedule ends. Must be after start_rotations_at. Shifts after it are removed. Leave it out to keep the rotation running.
teamId string
Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.
timezone string | null
Time zone for working_hours and for handovers across daylight saving changes. A new rotation with working_hours defaults to UTC. Leave it out to keep the previous time zone.
workingHours CreateOnCallRotationRequestWorkingHoursItem[]
The times the rotation pages anyone, as up to 50 weekly windows in local time. Windows are returned as HH:MM, sorted by day. A window that ends at or before its start runs overnight, and one with the same start and end covers the whole day. Without working_hours, or with an empty list, the rotation pages around the clock. Order doesn't matter.
Attributes
Section titled “Attributes”scheduleId string always set
The on-call schedule the rotation belongs to (the rotation's own id is the schedule's).
applyFrom string
Write-only: when the last change applied from (applyFrom as sent).
applyFromTimezone string
Write-only: the time zone of applyFrom (as sent).
effectiveTimezone string
The time zone working_hours are read in. Same as timezone when it's set, otherwise the schedule's default time zone, or UTC when neither is set.
endRotationsAt string
When the rotation schedule ends.
rotationInterval "hour" | "day" | "week"
Unit for rotation_length.
rotationLength number
How long each shift lasts, in rotation_interval units. A whole number of at least 1.
startRotationsAt string
When the rotation schedule starts.
teamId string
Team of the rotation's on-call schedule, such as t123.
timezone string | null
Time zone for working_hours and for handovers across daylight saving changes. A new rotation with working_hours defaults to UTC.
users string[]
E-mail addresses of users in the rotation, in shift order. Each must be a responder in the schedule's team.
workingHours OnCallRotationWorkingHoursItem[]
The times the rotation pages anyone, as up to 50 weekly windows in local time. Windows are returned as HH:MM, sorted by day. A window that ends at or before its start runs overnight, and one with the same start and end covers the whole day. Without working_hours, or with an empty list, the rotation pages around the clock. Order doesn't matter.
Lookup
Section titled “Lookup”OnCallRotation.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
scheduleId string required
The on-call schedule's id, or default.
teamId string
Team that owns the schedule, such as t123. Defaults to the credentials' team.