Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

API Endpoint that provides start/end time for rotation

jsimon December 14, 2023

I am working to create a custom 'Who's On-call' widget for opsgenie similar to this: https://demo.pagerbeauty.sergii.org/v1/schedules/PDUQGYJ.html - Specifically I'm stuck creating the 'From' and 'To' fields indicating how long they are on-call for.

I am struggling to find an API endpoint that will give me the start and end time of a given rotation for a specific user that is currently on-call. The rotations endpoint looks to only provide the start and end time of the entire rotation. 

Is there an API endpoint that can provide the start time and end time of the current rotation for a specific user?

Screenshot 2023-12-14 165720.png

2 answers

1 accepted

1 vote
Answer accepted
jsimon December 19, 2023

For posterity, Get Schedule Timeline has the start and end time of a user on a rotation.

0 votes
Rafael Meira
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2023

Hey @jsimon 

The Opsgenie API doesn't provide a direct endpoint to get the start and end time of the current rotation for a specific user.

You could use the combination of "Get Schedule" (`GET /v2/schedules/{identifier}`) and "Get On-Call" (`GET /v2/schedules/{identifier}/on-calls`) APIs to achieve this.

Get the schedule details, iterate over the rotations to find the specific user, then use "Get On-Call" API to get the start and end time of that user's on-call period.

Let me know if you have any questions or face any issues.
Also, in case you need further assistance, I would recommend you open a formal ticket with our support here: https://support.atlassian.com/opsgenie/ 


Best,
Rafa

jsimon December 18, 2023

Thanks Rafa.

 

Not sure if I am misunderstanding your explanation or you misunderstood my question.

"Get the schedule details, iterate over the rotations to find the specific user, then use "Get On-Call" API to get the start and end time of that user's on-call period."

I am not clear how this will work as the "Get On-Call" API does not return anything about the time for that user's shift (though I think it should) and the Get Schedule" API only returns the start and end data of the rotation as a whole - which is less than useful

I suppose it's possible to extrapolate the start and end times based on the "timeRestriction" fields that are returned from the "Get-Schedule" API, but I would argue that this should be done on the API side and be returned with the "Get-Oncall" API.

Regardless, I've opened a support ticket to look into this further.

 

Thanks for the help.

Rafael Meira
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2023

@jsimon 

You're correct that the "Get Schedule" API only provides the start and end times for the entire rotation, and the "Get On-Call" API doesn't offer specific start and end times for a user's shift.

Your point about extrapolating the times based on the "timeRestriction" fields is valid, but as you've noted, it would require additional calculations on your end. It's a viable workaround for now, although not as straightforward as having the API provide the data directly.

We appreciate the feedback about enhancing the "Get On-Call" API to include this feature. We strive to improve our services based on user feedback and your input is valuable to us. I will create a Feature Request on this topic.

I'm glad to hear you've opened a support ticket. 

Best,

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events