On-call schedules
An OnCallSchedule says who on a team
is on call, and when. Who is on call comes from the schedule’s
OnCallRotation, people taking turns
in shifts of a set length, plus overrides made in the web app. An escalation
policy pages whoever is on call with a current_on_call step.
The free plan includes one on-call schedule per team: a second one fails with a
typed Forbidden. The schedule’s live test is gated behind a paid plan, and the
rotation is tested against the offline mock only; see
Compatibility.
Create a schedule
Section titled “Create a schedule”const schedule = yield* BetterStack.Incidents.OnCallSchedule("primary", { name: "Primary on-call",});Every prop updates in place; teamId replaces the schedule. Deleting a
schedule also deletes its rotation and events.
Put people in a rotation
Section titled “Put people in a rotation”A schedule has exactly one rotation. users are the e-mail addresses of
responders in the schedule’s team, on call in turns of rotationLength
rotationIntervals from startRotationsAt:
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",});Any change re-sends the whole rotation and replaces the schedule’s future shifts; overrides stay. Putting someone in a rotation makes them reachable by every escalation policy that pages the schedule.
Business hours only
Section titled “Business hours only”workingHours limits the shifts to weekly windows in the rotation’s
timezone:
const support = yield* BetterStack.Incidents.OnCallSchedule("support", { name: "Support" });yield* BetterStack.Incidents.OnCallRotation("support-rotation", { scheduleId: support.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" }, ],});Page the schedule
Section titled “Page the schedule”An escalation step with a current_on_call member and the schedule’s id
pages whoever is on call at that moment:
yield* BetterStack.Incidents.EscalationPolicy("primary-policy", { name: "Primary on-call", steps: [ { type: "escalation", waitBefore: 0, stepMembers: [{ type: "current_on_call", id: schedule.id }], }, ],});The team’s default schedule
Section titled “The team’s default schedule”Every team has a default schedule that this resource doesn’t create. Don’t
reference it with OnCallSchedule.lookup({ id: "default" }): the live API
answers 500 for that id.
Where next
Section titled “Where next”- Escalation policies: the steps that page the schedule.
- Reference:
OnCallSchedule,OnCallRotation. - Better Stack: On-call calendars (API).