Add a responder to alert via rest api (team id question)

Boris Zozoulia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2024

Hi,

Attempting to add a responder via rest API to my alert, I am getting confused about the team id I have to use.

 

the API rest endpoint in question:

https://api.opsgenie.com/v2/alerts/:identifier/responders

 

As per the doco (https://docs.opsgenie.com/docs/alert-api#add0responder-to-alert), I should use the payload:


{
"responder": {
"type": "team",
"id": "TEAM_ID"
}
}

 

My question is on getting the TEAM_ID value.

We have recently moved to Jira integrated Ops genie experience from the standalone Ops Fenie, which results in using the Jira Atlassian teams, instead of native Ops Genie ones.

Setting the responders via the rest API, using the Jira Atlassian team ID , yields the error:

 

 
{

"success": false,

"action": "Add Responder",

"processedAt": "2024-08-06T01:35:19.345Z",

"integrationId": "",

"isSuccess": false,

"status": "Team with id [og-1c0cda02-XXX-XXX-XXX-e3f2d3399731] does not exist.",

"alertId": "",

"alias": ""

}
Please note the team ID with the "og" prefix - is the original team migrated from ops genie.
When I manually assigned the alert to this team via the UI and got the alert details via the API, I could see the responder's field contained some ID of a team, which I don't understand how I can get.
That ID somehow corresponds internally to a team I am after, but I cannot find it in any of the APIs.
Trying to use Ops Genie Teams API- produces a result
{ "message": "This service only for Standalone Opsgenie customers. Please use JIRA team APIs", }
Please advise.

3 answers

1 accepted

1 vote
Answer accepted
Boris Zozoulia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2024

Looking further into it - i am able to get the list of these via GraphQL

https://team.atlassian.com/gateway/api/graphql

 

 

query example {
jira {
   allJiraProjects(cloudId: "MY_CLOUD_ID", filter: {types: [SERVICE_DESK]}) {
     pageInfo {
       hasNextPage
     }
     edges {
       node {
         key
         name
         opsgenieTeamsAvailableToLinkWith {
           pageInfo {
             hasNextPage
           }
           edges {
             node {
               id
               name
             }
           }
         }
       }
     }
   }
}
}

0 votes
Nathan Given
Contributor
November 20, 2024

You can now use the Teams Public API: https://developer.atlassian.com/platform/teams/rest/v1/api-group-teams-public-api/#api-gateway-api-public-teams-v1-org-orgid-teams-get

It was implemented October 2024: https://jira.atlassian.com/browse/CLOUD-11862

The authentication is to use an Authorization header, with Basic base64_encoded_username:API_token

You can get an API token from https://id.atlassian.com/manage-profile/security/api-tokens

You can get the org id from admin.atlassian.com OR

https://sitename.atlassian.net/gateway/api/graphql

Run this:

query tenantData {
tenantContexts(hostNames: ["sitename.atlassian.net"]) {
cloudId
orgId
}
}

 You should see your cloudId and your orgId:

 

{
"data": {
"tenantContexts": [
{
"cloudId": "redacted",
"orgId": "redacted"
}
]
},
"extensions": {
"gateway": {
"request_id": "186141fa756f48b484402dbb902a3d28",
"crossRegion": true,
"edgeCrossRegion": true
}
}
}
0 votes
Boris Zozoulia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 5, 2024

It is also possible to add responders by team name, like so

 

{ 
"responder": {
"type": "team",
"name": "My Team"
}
}

this works fine, for our case, however, it is possible that there are multiple Atlassian teams, named "My Team", and in such case - the assignment result is unpredictable, as we cannot guarantee, which of the "My Teams" the alert will be assigned to.

 

Having said that - I do not see any documentation, which describes how the assign responder by name functionality works, yet the API accepts such a payload and processes it successfully.

 

Please advise further

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events