On-call as an API
Read who is on call, and manage schedules, rotations and overrides from code.
Who is on call is data. Read it to route a support request, to tag a dashboard, to mention the right person in chat. Change it from code for swaps, vacations and follow-the-sun handoffs.
#Who is on call now
const { schedules } = await treason.oncall.get("payments"); // a team id or exact name
for (const s of schedules) console.log(s.scheduleName, s.onCall?.name ?? "nobody");treason oncall payments
curl "$TREASON_API_URL/v1/oncall?team=payments" -H "Authorization: Bearer $TREASON_API_KEY" # any alert, read or admin key worksPass at to ask about another moment: GET /v1/oncall?team=payments&at=2026-12-24T09:00:00Z. Overrides win over rotations; when two overrides overlap, the one that started later wins.
onCall is null when nobody is on call for a schedule. That is worth alerting on: an alert for that schedule would skip to the next escalation step.
#Schedules
A schedule has a time zone and one or more rotation layers; higher layers win over lower ones.
await treason.schedules.create({
name: "Primary",
teamId,
timezone: "America/New_York",
layers: [{
rotationStart: "2026-10-12T13:00:00.000Z", // the first handoff
rotationLength: { days: 7, hours: 0 }, // each person is on call for a week
handoffTime: "09:00", // wall-clock time in the schedule's zone
members: [ana.id, bo.id, cy.id], // in order, then around again
}],
});Handoffs happen at the same wall-clock time through daylight-saving changes: "09:00 Monday" stays 09:00 in March and November. A rotation shorter than a day (rotationLength: { days: 0, hours: 12 }) runs on absolute hours instead.
rotationStartis an instant. Its local date, in the schedule's time zone, is the first handoff date. If you build it from a date picker, convert the date and handoff time in the schedule's zone to UTC; do not use midnight UTC.
#Overrides
await treason.schedules.addOverride(scheduleId, {
userId: bo.id,
startsAt: new Date("2026-12-24T00:00:00Z"),
endsAt: new Date("2026-12-27T00:00:00Z"),
});An override puts a person on call for a range instead of the rotation. Remove it with removeOverride. GET /v1/schedules/{id} includes overrides from the last 90 days onward, so you can draw a calendar.
#Rotation as code
Because PUT /v1/schedules/{id} replaces the whole schedule, you can keep rotations in your repository and apply them in CI:
const desired = JSON.parse(await readFile("oncall/primary.json", "utf8"));
const existing = (await treason.schedules.list()).schedules.find((s) => s.name === desired.name);
existing ? await treason.schedules.replace(existing.id, desired) : await treason.schedules.create(desired);#Deleting
A schedule cannot be deleted while an escalation step still points at it, because that would silently page nobody (409 conflict). Move or edit the policy first.