Incidents.OnCallSchedule
A Better Stack on-call schedule: says who on the team is on call and when.
Who is on call comes from the schedule’s OnCallRotation (people in
turns, with shifts of a set length) plus overrides. Escalation policies page
it with a current_on_call step member whose id is the schedule’s id.
Every prop updates in place; teamId replaces the schedule. name
defaults to a generated unique name. Removing slackGroupHandle stops
tagging who is on call in Slack. Deleting a schedule also deletes its
rotation and events. The team’s default schedule is not created by this
resource (look it up by its numeric id: the live API answers 500 for
lookup({ id: "default" })).
The free plan includes one on-call schedule per team: creating another
fails with a typed Forbidden (“Your plan includes one on-call schedule per
team. Upgrade your plan to add more.”).
Creating a schedule with a rotation
Section titled “Creating a schedule with a rotation”A weekly rotation the on-call escalation policy pages
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",});yield* BetterStack.Incidents.EscalationPolicy("primary-policy", { name: "Primary on-call", steps: [ { type: "escalation", waitBefore: 0, stepMembers: [{ type: "current_on_call", id: schedule.id }] }, ],});Looking up a schedule by name
Section titled “Looking up a schedule by name”Fails with AmbiguousLookup when several schedules share the name
const primary = BetterStack.Incidents.OnCallSchedule.lookup({ name: "Primary on-call" });name string
Schedule name. Defaults to a unique name generated from the stack, stage and logical id.
slackGroupHandle string | null
The handle of a Slack user group that always holds whoever is on call, without the
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.
useExistingSlackGroup boolean
Whether slack_group_handle names a user group that already exists in your connected Slack workspace, instead of a new group we create. An existing group keeps its other members. A handle that one of your Slack user groups already uses is refused unless this is true, and a handle no group uses is refused when it's true. Sent without slack_group_handle, the setting applies to the current handle. Sending null or leaving it out keeps the schedule's current choice.
Attributes
Section titled “Attributes”id string always set
The on_call_schedule's id.
defaultSchedule boolean
Whether this is your team's default on-call schedule.
name string | null
Schedule name. null only on a primary schedule without a name of its own.
shifts OnCallScheduleShiftsItem[]
Who is on call from from to to, oldest first. Each entry is one part of a shift and the people on call during it. Where an override covers part of a shift, the override's entry replaces that part. Without from and to, shifts holds only the shift running now. Returned when you get or list schedules.
slackGroupHandle string | null
The handle of a Slack user group that always holds whoever is on call, without the
slackGroups OnCallScheduleSlackGroupsItem[]
The state of the handle's user group in each connected Slack workspace.
teamId string
Team that owns the schedule, such as t123.
teamName string
Name of the team that owns the schedule.
useExistingSlackGroup boolean
Whether slack_group_handle names a user group that already exists in your connected Slack workspace, instead of a new group we create. An existing group keeps its other members. A handle that one of your Slack user groups already uses is refused unless this is true, and a handle no group uses is refused when it's true. Sent without slack_group_handle, the setting applies to the current handle.
Lookup
Section titled “Lookup”OnCallSchedule.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
teamId string
Team that owns it, such as t123. Defaults to the credentials' team.