Can't set team on a schedule via the API?


(AC) #1


Via the web UI one can associate a schedule with a team, but I’m not seeing how this same thing can be done via the REST API. Am I misreading the docs, or is this maybe a feature that’s not yet available?


(Paul) #2

There isn’t a way to associate a schedule with a team when creating it via the REST API. This is a good question that requires a bit of an explanation; in order to explain why this is the case, I will provide a bit of background around how teams and schedules are related in PagerDuty.

Schedules are designed to be associated with teams by virtue of the escalation policies they are in. The reasoning behind this is that users who are in schedules which are not in escalation policies are effectively not on call (since the schedule is not in use and there is no chance of them being assigned an incident through the schedule).

Once a schedule is put inside an escalation policy, those users are on call for that escalation policy. You can then associate this escalation policy to a team (along with the schedules and users that are inside it) in the web UI by editing that team, clicking in the escalation policy field, and typing in or selecting that escalation policy. From the REST API, this can be done using either the POST escalation policy or PUT escalation policy endpoint. This is the approach I would recommend for your and most others’ use cases.

The reason we decided to allow schedules to be associated with a team in the web UI is to accommodate a very narrow use case. With advanced permissions, some users are only allowed to edit their team’s objects (schedules, services, escalation policies). If one of these users wishes to create a new schedule and put it inside their team’s escalation policy, they can only do so if that schedule is assigned to their team.

So to accommodate this use case, the Team dropdown is available when creating a new schedule in the web UI. However, to avoid confusion in how schedules and teams are normally related, this option is not available in the REST API.

(AC) #3

@prupke Thanks for your extremely helpful and quick reply!

(system) #4

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.