//native
/**
* Create Schedule Override
* Override an on-call schedule to put a specific user on call for a time window. Start and end use ISO 8601 with an explicit UTC offset (e.g. 2026-06-02T08:00:00-07:00) — always include the offset so the window lands in the right slot.
*/
export async function main(
auth: RT.Pagerduty,
schedule_id: string,
user_id: string,
start: string,
end: string,
) {
const response = await fetch(
`https://api.pagerduty.com/schedules/${schedule_id}/overrides`,
{
method: "POST",
headers: {
Authorization: `Token token=${auth.token}`,
"Content-Type": "application/json",
Accept: "application/vnd.pagerduty+json;version=2",
},
body: JSON.stringify({
overrides: [
{ start, end, user: { id: user_id, type: "user_reference" } },
],
}),
},
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 days ago