How to get all Teams in JIRA via the cloud rest api?

Christof Bornhoevd
Contributor
May 1, 2023

How can I retrieve all teams in JIRA via the JIRA rest api, something of the form of  /rest/api/3/team 

3 answers

4 votes
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 1, 2023

Looking at https://MYSITE.atlassian.net/jira/people/search

I see a call to this endpoint:

https://boomaster.atlassian.net/gateway/api/v3/teams/search?organizationId=MYORGANIZATIONID

Which returns JSON that seems to include a bunch of teams.

Oliver Siebenmarck _Polymetis Apps_
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.
May 2, 2023

Just two quick notes on that particular endpoint:

That's not part of the product's APIs which means that individual admins can use their personal API tokens to access this, but it is out of reach for Connect and Forge apps.

And if I am not totally mistaken, it's also not part of the official APIs, ie you should not rely on using for any production workload, as you are basically hacking ;-) 

Like Darryl Lee likes this
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 2, 2023

@Oliver Siebenmarck _Polymetis Apps_ is quite right. This is totally a hack, gathered from sniffing the Search People/Teams page. 

Totally correct that this is probably only usable for unofficial admin work, like one-time scripts, etc. certainly not for apps or production automation things. 

Or if you do use it for such tasks you'll want to make sure you have robust error/sanity checks to confirm the endpoint is still "working".

Christof Bornhoevd
Contributor
May 3, 2023

Thanks a lot for looking into this, Does this mean there is no official endpoint teams in JIRA ?

Like # people like this
Christof Bornhoevd
Contributor
May 3, 2023

Is there a way to get team data via JQL?

Oliver Siebenmarck _Polymetis Apps_
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.
May 4, 2023

Hi @Christof Bornhoevd ,

as far as I am aware, there isn't an official REST API to get the teams. @Darryl Lee 's suggestion should work great, but isn't something I would feel comfortable putting into a product that a lot of people rely on. If it were just for me and some one-off scripts, then it would absolutely be the way to go.

The other option you could explore is the GraphQL API which, if I remember correctly, also has some information on teams. Personally, I find GraphQL very weird to work with, but the data should be there. Another thing to keep in mind, is that the GraphQL API does not seem to be meant for marketplace apps, so if that is where you are going with this, then you should check if that would work. Again, for some low-risk internal scripting, it should be more than fine.

Hope that helps,
 Oliver

Evgen Kyselgov June 5, 2023

Hi @Oliver Siebenmarck _Polymetis Apps_ , do you know if there are any plans to add Teams support to the REST API? The commercial application, that i work with, uses a REST API and it would be nice to see Teams support in it.

Oliver Siebenmarck _Polymetis Apps_
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.
June 5, 2023

Hi @Evgen Kyselgov ,

Unfortunately, I have no idea. There is a public roadmap here: https://trello.com/b/8XBuIeIu/atlassian-platform-for-developers-roadmap, but it doesn't not mention a teams API. Does not mean that it isn't the works though.

If you really want/need this, it might be a good idea to reach out to Atlassian directly. 

David Bakkers
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.
April 29, 2024

To anyone else who stumbles on this thread, I would like to make a personal statement in support of what @Oliver Siebenmarck _Polymetis Apps_ said

The REST API endpoint at:

https://{yourDomain}.atlassian.net/gateway/api/v3/teams/search

is an internal one used for creating content for Jira's GUI. You're not supposed to be accessing directly! Don't use it and expect support from anyone at Atlassian.

Use the official Teams REST APIs that @Andreas Krupp has mentioned

If you're silly enough to use internal API endpoints directly, despite being warned not to, then that's your problem. But, for goodness sake, don't come over to the Developer's Community with idiotic questions about how you can't get it to work with method XYZ or function in Forge, Connect, or whatever else.

/rant

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 14, 2024

Oh hey, I don't mean to be silly and I would NEVER ask an idiotic question over in the Developer's Community, but I was just poking at this because, ugh, we have so many teams now. 

I wanted to point out that the internal unofficial endpoint I provided above actually returns MORE RESULTS and MORE DATA than the official one (that sometime between August and October 2024 added the call to list all teams):

https://{YOURSITE}.atlassian.net/gateway/api/public/teams/v1/org/{YOURORGID}/teams

So, that official API endpoint only returns 48 teams.

But when I "Browse all teams" in the UI I see 80 (ugh) Teams created by my users. And lo and behold, the internal unofficial API endpoint also returns 80 Teams.

Looking at what the unofficial API endpoint returns, I don't see any difference between one of the Teams "missing" from the unofficial API response and one that is visible both in the UI and in the unofficial API response. Here's two such Teams:

  {
    "id": "ari:cloud:teams::team/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX",
    "displayName": "DEVREL Comm Approvers",
    "description": "",
    "state": "ACTIVE",
    "discoverable": "DISCOVERABLE",
    "membershipSettings": "MEMBER_INVITE",
    "restriction": "ORG_MEMBERS",
    "organizationId": "{MYORGID}",
    "pseudoOrganizationId": null,
    "memberCount": 4,
    "includesYou": false,
    "isVerified": false,
    "largeHeaderImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/gradients/6.svg",
    "smallHeaderImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/gradients/6.svg",
    "largeAvatarImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/6.svg",
    "smallAvatarImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/6.svg"
  },
  {
    "id": "ari:cloud:teams::team/XXXXXXX-YYYY-YYYY-YYYY-XXXXXXX",
    "displayName": "Spoken Subs",
    "description": "",
    "state": "ACTIVE",
    "discoverable": "DISCOVERABLE",
    "membershipSettings": "MEMBER_INVITE",
    "restriction": "ORG_MEMBERS",
    "organizationId": "{MYORGID}",
    "pseudoOrganizationId": null,
    "memberCount": 6,
    "includesYou": false,
    "isVerified": false,
    "largeHeaderImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/gradients/5.svg",
    "smallHeaderImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/gradients/5.svg",
    "largeAvatarImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/5.svg",
    "smallAvatarImageUrl": "https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/5.svg"
  },

But anyways, the official API does only has "Spoken Subs", not "DEVREL Comm Approvers", and there's much less data:

    {
      "teamId": "XXXXXXX-YYYY-YYYY-YYYY-XXXXXXX",
      "organizationId": "{MYORGID}",
      "displayName": "Spoken Subs",
      "description": "",
      "teamType": "MEMBER_INVITE"
    },

The IDs do match.

SO UH, yes, UNOFFICIAL. Idiotic. Silly!

But also more accurate?

Like Dave Liao likes this
3 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

@Oliver Siebenmarck _Polymetis Apps_  @Darryl Lee

 

After digging through some other community posts, as well as experimenting with graphQL, here is a way to get all the teams in your organisation:

Inspried by: https://community.developer.atlassian.com/t/invalid-organization-ari-using-teamsearchv2-in-the-graphql-api/77375

Head on to:

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

get your cloudId and orgId

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

The call experimental teams search graphql API

query MyQuery {
team @optIn(to: "Team-search-v2") {
teamSearchV2(organizationId: "ari:cloud:platform::org/ORG_ID_FROM_ABOVE", siteId: "CLOUD_ID_FROM_ABOVE") {
pageInfo {
hasNextPage
}
nodes {
team {
displayName
}
}
}
}
}

Please note - this API would return a paginated result of pagesize 30, you will need to figure out how to get the next pages, you can specify first: 100 parameters in the teamSearchV2 to get the first 100, but ideally it should be a paginated approach. Ill leave it up to you how to do it

 

 

Nick Pirocanac
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 2, 2024

Updating with the below info from the V1 teams rest API, combined with the GraphQL query from Boris got me to: 

 

POST https://{your domain}.atlassian.net/gateway/api/graphql
{

    "query": "query getTenantOrg {tenantContexts(hostNames:[\"{your domain}.atlassian.net\"]) {cloudId,orgId}}"

}
Which gets you the cloudId and the magical orgId which you can then use here: 

GET https://{your domain}.atlassian.net/gateway/api/public/teams/v1/org/{your orgId}/teams
This will then return you a list of the teams in your org. The Jira UI is getting the orgId from GraphQL as well. 
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 14, 2024

Yikes, that's a lot of work to get the Org ID. This might be easier:

Like Dave Liao likes this
1 vote
Andreas Krupp
Contributor
March 20, 2024
Neil Vachharajani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2024

Is this API available to Connect apps? And is there anyway to use the API to get a list of all the teams?

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 22, 2024

Hey so this is a bit old, but since @Andreas Krupp found the official API and then @David Bakkers made sure to emphasize that using the unofficial API that I found is silly and maybe idiotic, I will point out that after @Oliver Siebenmarck _Polymetis Apps_ correctly pointed out that it was unofficial, I replied that he was quite right:

This is totally a hack, gathered from sniffing the Search People/Teams page. 

Totally correct that this is probably only usable for unofficial admin work, like one-time scripts, etc. certainly not for apps or production automation things. 

Or if you do use it for such tasks you'll want to make sure you have robust error/sanity checks to confirm the endpoint is still "working".

THAT BEING SAID: the Official Teams Public API can't actually do what the original poster asked for. Here's what you get there:

Which is... fine, except it assumes you have the Team ID. Where the heck are you supposed to get that when there is no SEARCH or GETALL method?

Look, if somebody can give us some examples of GraphQL, that'd be swell. I mean, will I need to use OAuth? God help me, no.

But I'm going to take a wild guess that the original poster @Christof Bornhoevd was trying to get a list of Teams because Teams are a mess (this is an article I still need to write), and he's just trying to get a handle on HOW MANY teams he has, and what they're named.

The API I found works fine for that, and considering it's still functioning after a year (and I still haven't learned GraphQL) is I guess evidence that sometimes a hack will work.

But YES, you absolutely shouldn't try to write an app in Force or Connect or anything talking to this API. That would definitely be idiotic. ;-}

Like # people like this
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

Totsally right @Darryl Lee !
the Official Teams Public API can't actually do what the original poster asked for

I believe @it is offensive, to give statements, assessing the "idiocy" of some questions posted. Have a Look at some of the answers! :D

siruntamable
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 20, 2024

@Darryl Lee  @Boris Zozoulia  Interestingly Official Teams Public API  has a GET
Get a list of teams api now. Not sure if this was released recently.

Like Boris Zozoulia likes this
YY Brother
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 20, 2024

It can be used. You could have a try @siruntamable 

siruntamable
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 26, 2024

It works but getting the orgId was a pain, I ended up using the graphql api to get the orgId as mentioned above in one of the comments. 

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 14, 2024

For @siruntamable and others, here's the official guidance on how to find your Organization ID:

Like Dave Liao likes this
Adrian V_Martin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 17, 2024

Hi @Darryl Lee , the endpoint you provided 

https://boomaster.atlassian.net/gateway/api/v3/teams/search?organizationId=MYORGANIZATIONID

proved to be very useful.

Would it be possible to also retrieve the team members for each team?

 

Thank you

Adrian V_Martin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 18, 2024

Update: I've found a way to get team members

We can do this by using official endpoint provided by atlassian

Does anyone know how to paginate the endpoint provided by @Darryl Lee?(I'm getting only 99 teams)

startAt doesn't work.

 

Thank you

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 18, 2024

Ugh. So yeah, turns out it's a bad idea to use a hack. :-}

It looks like Atlassian is no longer using the endpoint I found. :-{{

The People and teams page (https://YOURSITE.atlassian.net/jira/people/search/teams) is ONLY using graphql calls now to find all the Teams, which @Boris Zozoulia documented above.

I'm looking at the Developer panel and seeing a POST to this endpoint:

And yeah, that's documented here:
  • teamSearchV2 - 

    Returns the search result for teams matching the given query in the specified site and organization. Please provide siteId if present, in its raw id form (i.e. not ARI). If siteId is not present, please provide "None" string. Query can be empty. Optionally a limit (max 100), sort and a cursor can be supplied.

Ugh, yeah, so then you have to dig out pageInfo.endCursor from each response, and use that in the after part of the GraphQL query, which is weird, because that argument isn't documented as such, and you would _think_ that you should instead be submitting pageInfo.startCursor.

Feh, I guess this is standard GraphQL: https://graphql.org/learn/pagination/

Shudder.

Perhaps I should play with graphqurl or something that makes this less scary for me.

Suggest an answer

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

Atlassian Community Events