• 148
    • 53
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Summary

      As an administrator I would like to have a REST API endpoint that I can call in order to export users to CSV. The same CSV export you can get from the instance user management when you click on 'export all users' documented in the below page:

      Workaround

      It is possible to grab the cookie from an active site-admin session from the browser and then use it to authenticate a REST API POST request sent to the below internal endpoint (replace <CLOUD-ID> with your real cloud instance id):

      https://admin.atlassian.com/gateway/api/adminhub/um/site/<CLOUD-ID>/users/export
      

      As the body you can send something like:

      {
      includeApplicationAccess: true
      includeGroups: false
      includeInactiveUsers: true
      selectedGroupIds: []
      }
      

      Please notice this is just a workaround, the endpoint is not official, not documented and may change over time. You may find a sample Python script in this link.

      There is an updated Python script provided by the DEV team as the endpoint API is no longer valid link here

       

            [ID-8451] REST API endpoint to export all users to CSV

            Alfredo added a comment -

            4326607df174 workaround worked well, however with the last browsers update to encrypt cookies, the browser_cookie3 approach has been blocked, so, I think, will not be possible for a while.

            Any other workaround someone could have thought?

            And following d108c8e54c86 comment, any updates on then this issue will be addressed to get an official API available? This export is a critical step for project control. 

            Alfredo added a comment - 4326607df174 workaround worked well, however with the last browsers update to encrypt cookies, the browser_cookie3 approach has been blocked, so, I think, will not be possible for a while. Any other workaround someone could have thought? And following d108c8e54c86 comment, any updates on then this issue will be addressed to get an official API available? This export is a critical step for project control. 

            Using this internal endpoint works for us; however, there are instances where the 'region' specified does not match the correct S3 storage, causing the run to fail on the second if/else condition. Could we kindly request the list of regions being used (e.g., 'us-west-2', 'eu-east-1') for this endpoint?

            Additionally, do you have any updates on when this will be addressed and if there will be an official API available?

            delacruz.jm.2 added a comment - Using this internal endpoint works for us; however, there are instances where the 'region' specified does not match the correct S3 storage, causing the run to fail on the second if/else condition. Could we kindly request the list of regions being used (e.g., 'us-west-2', 'eu-east-1') for this endpoint? Additionally, do you have any updates on when this will be addressed and if there will be an official API available?

            Update for orgs with new user management experience

            import argparse
            import time
            
            import browser_cookie3
            import requests
            
            cookies = browser_cookie3.chrome()  # could do browser_cookie3.load() for arbitrary browser
            
            parser = argparse.ArgumentParser(description='Download users from a Cloud Org')
            parser.add_argument('cloud_org_id', type=str, help='Unique ID of the Cloud Org')
            parser.add_argument('output_file', type=str, help='Output file name')
            
            args = parser.parse_args()
            
            # update this according to your org
            url = 'https://admin.atlassian.com/gateway/api/adminhub/um/org/{}/exports/users'.format(args.cloud_org_id)
            
            # update according to needs
            data = {
                  "includeApplicationAccess": "true",
                  "includeGroups": "true",
                  "includeInactiveUsers": "true",
                  "selectedGroupIds": []
               }
            
            response = requests.post(url, json=data, cookies=cookies)
            if not response.ok:
                print(f"Failed to export csv with code : {response.status_code} {response.text}")
                exit(1)
            
            
            
            
            exportKey = response.headers.get('exportKey')
            
            # get export ID (A/B/C -> C)
            exportID = exportKey.split('/').pop()
            
            # wait for background tasks to complete - adjust based on size of users
            time.sleep(60)  # wait long enough here
            
            # Update this if needed, you can find this information by hovering over to the 'Download CSV file' button in the email
            region = 'us-west-2'
            
            # Hit download endpoint
            downloadUrl = 'https://admin.atlassian.com/gateway/api/adminhub/um/org/{}/exports/{}?region={}'.format(args.cloud_org_id, exportID, region)
            response = requests.get(downloadUrl, cookies=cookies)
            
            if response.ok:
                with open(args.output_file, "w") as cloudcsvfile:
                    cloudcsvfile.write(response.text)
                print("Successfully exported csv to file")
            else:
                print(f"Failed to export csv with code {response.status_code}")
            

            Yuji Sakai (Inactive) added a comment - Update for orgs with new user management experience import argparse import time import browser_cookie3 import requests cookies = browser_cookie3.chrome() # could do browser_cookie3.load() for arbitrary browser parser = argparse.ArgumentParser(description= 'Download users from a Cloud Org' ) parser.add_argument( 'cloud_org_id' , type=str, help= 'Unique ID of the Cloud Org' ) parser.add_argument( 'output_file' , type=str, help= 'Output file name' ) args = parser.parse_args() # update this according to your org url = 'https: //admin.atlassian.com/gateway/api/adminhub/um/org/{}/exports/users' .format(args.cloud_org_id) # update according to needs data = { "includeApplicationAccess" : " true " , "includeGroups" : " true " , "includeInactiveUsers" : " true " , "selectedGroupIds" : [] } response = requests.post(url, json=data, cookies=cookies) if not response.ok: print(f "Failed to export csv with code : {response.status_code} {response.text}" ) exit(1) exportKey = response.headers.get( 'exportKey' ) # get export ID (A/B/C -> C) exportID = exportKey.split( '/' ).pop() # wait for background tasks to complete - adjust based on size of users time.sleep(60) # wait long enough here # Update this if needed, you can find this information by hovering over to the 'Download CSV file' button in the email region = 'us-west-2' # Hit download endpoint downloadUrl = 'https: //admin.atlassian.com/gateway/api/adminhub/um/org/{}/exports/{}?region={}' .format(args.cloud_org_id, exportID, region) response = requests.get(downloadUrl, cookies=cookies) if response.ok: with open(args.output_file, "w" ) as cloudcsvfile: cloudcsvfile.write(response.text) print( "Successfully exported csv to file" ) else : print(f "Failed to export csv with code {response.status_code}" )

            It looks like the API request was changed, in our case works this one:
            https://admin.atlassian.com/gateway/api/adminhub/um/org/{}/exports/users
            so need to change from /site/ to /org/

            Pavel Stroitelev added a comment - It looks like the API request was changed, in our case works this one: https://admin.atlassian.com/gateway/api/adminhub/um/org/ {}/exports/users so need to change from /site/ to /org/

            Praneeth, that's a cool workaround but assumes execution on a developer laptop - unfortunately we need to have a solution export users from a fully automated procedure. 
            Doesn't solve for me :/

            Emanuele Di Saverio added a comment - Praneeth, that's a cool workaround but assumes execution on a developer laptop - unfortunately we need to have a solution export users from a fully automated procedure.  Doesn't solve for me :/

            Praneeth Garimella added a comment - - edited

            Updated Python script as the old endpoint API will be removed.

            import argparse
            import time
            
            import browser_cookie3
            import requests
            
            cookies = browser_cookie3.chrome()  # could do browser_cookie3.load() for arbitrary browser
            
            parser = argparse.ArgumentParser(description='Download users from a Cloud site')
            parser.add_argument('cloud_site_id', type=str, help='Unique ID of the Cloud Site')
            parser.add_argument('output_file', type=str, help='Output file name')
            
            args = parser.parse_args()
            
            # update this according to your site
            url = 'https://admin.atlassian.com/gateway/api/adminhub/um/site/{}/exports/users'.format(args.cloud_site_id)
            
            # update according to needs
            data = {
                  "includeApplicationAccess": "true",
                  "includeGroups": "true",
                  "includeInactiveUsers": "true",
                  "selectedGroupIds": []
               }
            
            response = requests.post(url, json=data, cookies=cookies)
            if not response.ok:
                print(f"Failed to export csv with code : {response.status_code} {response.text}")
                exit(1)
            
            
            
            
            exportKey = response.headers.get('exportKey')
            
            # get export ID (A/B/C -> C)
            exportID = exportKey.split('/').pop()
            
            # wait for background tasks to complete - adjust based on size of users
            time.sleep(60)  # wait long enough here
            
            # Update this if needed, you can find this information from the email
            region = 'us-west-2'
            
            # Hit download endpoint
            downloadUrl = 'https://admin.atlassian.com/gateway/api/adminhub/um/site/{}/exports/{}?region={}'.format(args.cloud_site_id, exportID, region)
            response = requests.get(downloadUrl, cookies=cookies)
            
            if response.ok:
                with open(args.output_file, "w") as cloudcsvfile:
                    cloudcsvfile.write(response.text)
                print("Successfully exported csv to file")
            else:
                print(f"Failed to export csv with code {response.status_code}")
            

            Praneeth Garimella added a comment - - edited Updated Python script as the old endpoint API will be removed. import argparse import time import browser_cookie3 import requests cookies = browser_cookie3.chrome() # could do browser_cookie3.load() for arbitrary browser parser = argparse.ArgumentParser(description= 'Download users from a Cloud site' ) parser.add_argument( 'cloud_site_id' , type=str, help= 'Unique ID of the Cloud Site' ) parser.add_argument( 'output_file' , type=str, help= 'Output file name' ) args = parser.parse_args() # update this according to your site url = 'https: //admin.atlassian.com/gateway/api/adminhub/um/site/{}/exports/users' .format(args.cloud_site_id) # update according to needs data = { "includeApplicationAccess" : " true " , "includeGroups" : " true " , "includeInactiveUsers" : " true " , "selectedGroupIds" : [] } response = requests.post(url, json=data, cookies=cookies) if not response.ok: print(f "Failed to export csv with code : {response.status_code} {response.text}" ) exit(1) exportKey = response.headers.get( 'exportKey' ) # get export ID (A/B/C -> C) exportID = exportKey.split( '/' ).pop() # wait for background tasks to complete - adjust based on size of users time.sleep(60) # wait long enough here # Update this if needed, you can find this information from the email region = 'us-west-2' # Hit download endpoint downloadUrl = 'https: //admin.atlassian.com/gateway/api/adminhub/um/site/{}/exports/{}?region={}' .format(args.cloud_site_id, exportID, region) response = requests.get(downloadUrl, cookies=cookies) if response.ok: with open(args.output_file, "w" ) as cloudcsvfile: cloudcsvfile.write(response.text) print( "Successfully exported csv to file" ) else : print(f "Failed to export csv with code {response.status_code}" )

            Not only doesn't feed us back with some input about ETA for this feature, but they announced me they want to clos down the POST /co/authenticate which we were automating to extract the token.

            Emanuele Di Saverio added a comment - Not only doesn't feed us back with some input about ETA for this feature, but they announced me they want to clos down the POST /co/authenticate which we were automating to extract the token.

            Is there a forecast of when it will be available?

            it would be very important for our customer.

            Cristina Riviello added a comment - Is there a forecast of when it will be available? it would be very important for our customer.

            Abhik Dey added a comment -

            Is this endpoint working ? This would make the work so much easier. Also I'd like to know, where can I find my Cloud Id ?

             

            Abhik Dey added a comment - Is this endpoint working ? This would make the work so much easier. Also I'd like to know, where can I find my Cloud Id ?  

            I guess they are too busy to respond. Honestly, I'm not too fond of products that are not user-friendly and without feedback. I saw open BUG reports, which had been opened 10+ years ago.  I will vote to switch to some alternative product as an admin of this zoo in my company.

            Oleksandr Borniak added a comment - I guess they are too busy to respond. Honestly, I'm not too fond of products that are not user-friendly and without feedback. I saw open BUG reports, which had been opened 10+ years ago.  I will vote to switch to some alternative product as an admin of this zoo in my company.

              2015ae912494 Stefan Scorse
              dbonotto Dario B
              Votes:
              189 Vote for this issue
              Watchers:
              114 Start watching this issue

                Created:
                Updated: