Bulk update Atlassian teams memberships for Atlassian Cloud using Postman and REST APIs

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

When to use this article

This article may be used any time there is a need to bulk update and add team memberships in Atlassian Cloud.



Identify your organisation’s user management

  1. Head to admin.atlassian.com. Select your organization if you have more than one.

Original

Centralized

As a site administrator or organization admin, Users is found under Product site.

As an organization admin, Users is found under Directory tab.

Prepare data

This article assumes a list of users and teams to be added/updated is already available/has been pre-determined. This article will walk users through the steps to map user and team id's.

Original data

Sample file


AB
​1EmailTeam
2vdillow@banc.lyTransformers
3ftoten2@banc.lyPlatform CORE
4amelmeth@banc.lyPipedream

Get user identifiers

  1. Go to admin.atlassian.com. Select your organization if you have more than one.
  2. This step is different depending on your user management experience:
    - Original: Select the site's name and URL to open the Admin for that site, then select Users.
    - Centralized: Select Directory > Users.

  3. This step is different depending on your user management experience:
    - Original: Select Export users.
    - Centralized: At the top of the screen, select > Export users.

  4. Select the users that you’d like to export:

    • All users in your site/organization – Include all users in your site/organization, across all groups.

    • Users from selected groups only – Only includes users in the groups you select.

  5. Select "All users" to include all active, suspended and deactivated users.

  6. Select Export users.
  7. An email will be sent when the CSV file is ready to download. Check your junk or spam folder if it’s taking awhile.
  8. Open the email and select Download CSV file.
  9. Rename the file to users.csv .
  10. Using a spreadsheet program, remove columns D onwards. This leaves a csv file with only three columns.
  11. Save the csv.

Sample file - users.csv


ABC
​1​User idUser name​email​
26155833c071axxx071ff5b24Janaye Floatjfloat@banc.ly
37a4b625f3fd5xxx24d741ac7Anissa Melmethamelmeth@banc.ly
4e2345d51eaa4xxx984e377ceVerna Dillowvdillow@banc.ly
53c5e0172a629xxx061259ed9Dorice Snapperdsnapper@banc.ly
6982bfd68520fxxx71daccb32Florian Totenftoten2@banc.ly

Get team identifiers

There is currently no systematic way to retrieve team names and id's while ID-8562 - Getting issue details... STATUS is not developed. It is also noted that team names are not unique.

  1. Using a spreadsheet program, create a spreadsheet with two columns.
  2. Label the columns teamId and teamName .
  3. Navigate to your Jira or Confluence site.
  4. In the top navigation bar, click Teams > Search People and Teams.
  5. In the search field labelled "Search for people and teams", search for a team where you need to identify the id.
  6. Select the team.
  7. Observe the URL - https://bancly.atlassian.net/wiki/people/team/d9ecb30d-f441-4731-b5ca-805fd35b153c
  8. The final GUID in the path represents the team id. In this case, it would be d9ecb30d-f441-4731-b5ca-805fd35b153c.
  9. Copy this value into the corresponding teamId for the row.
  10. Repeat the above steps for each team in question.
  11. Save the file as teams.csv .

Sample file - teams.csv


AB
​1teamIdteamName​
258fe54f2-33fc-47a5-8c05-b662fcdc64b8Pipedream
3c3abf5af-7fff-4268-ad9c-b74109c21a2aPlatform CORE
4eb47fb27-ad5c-441c-b753-c45b789b9229Transformers

Map data

  1. Open the original list of groups and users in a spreadsheet program.
  2. Into a new tab, import the previously created users.csv  . This assumes the tab is now called "users".
  3. Into a new tab, import the previously created teams.csv  . This assumes the tab is now called "teams".
  4. Open the spreadsheet tab containing the original list.
  5. Ensure columns A and B have the desired user email address and group name respectively.

  6. In cell C1, label the column header accountId  , noting the case is important.
  7. In cell C2, type:

    =XLOOKUP($A2,users!$C$2:$C$1000,users!$A$2:$A$1000,"")

    (warning) Ensure that A2:C1000 in the sheet users covers all users. This assumes column A contains the "Account id" and column C contains "email address" in users . The value of "1000" may need to be increased.

  8. Fill the remaining cells with an equivalent formula, ensuring $A2 is updated to the corresponding cell in the same row, but the remaining arguments remain the same.
  9. Perform a random check to ensure the lookup is behaving as expected.
  10. In cell D1, label the column header teamId  , noting the case is important.
  11. In cell D2, type:

    =XLOOKUP($B2,teams!$B$2:$B$1000,teams!$A$2:$A$1000,"")

    (warning) Ensure that A2:C1000 in the sheet groups covers all groups. This assumes column A contains the "Team id" and column B contains "Team name" in teams . The value of "1000" may need to be increased.

  12. Fill the remaining cells with an equivalent formula, ensuring $A2 is updated to the corresponding cell in the same row, but the remaining arguments remain the same.
  13. Perform a random check to ensure the lookup is behaving as expected.
  14. The resulting list should now be supplemented with account id's and team id's, and contain four columns.
  15. Save the resulting list as a csv.

Sample file


ABCD
​1EmailTeamaccountIdteamId
2vdillow@banc.lyTransformerse2345d51eaa4xxx984e377ceeb47fb27-ad5c-441c-b753-c45b789b9229
3ftoten2@banc.lyPlatform CORE982bfd68520fxxx71daccb32c3abf5af-7fff-4268-ad9c-b74109c21a2a
4amelmeth@banc.lyPipedream7a4b625f3fd5xxx24d741ac758fe54f2-33fc-47a5-8c05-b662fcdc64b8

Set up Postman

This section may be skipped if:

  • a collection named "Atlassian Cloud User Management" has previously been set up, and

  • an environment named "Atlassian Cloud" has previously been set up

Click here for instructions to set up Postman

Download Postman

  1. Download Postman from https://www.postman.com/downloads/

  2. Run Postman.

Create a new environment

  1. Click New, or type Ctrl + N (Windows/Linux) or Cmd + N (MacOS).

  2. Select “Environment”.

  3. Name the environment “Atlassian Cloud”.

  4. Set up the following variables:

    VariableTypeInitial value and Current valueComments

    cloudUrl

    default

    https://<yoursite>.atlassian.net

    Replace yoursite with your subdomain, e.g. acmecorp

    apiTokenEmailAddress

    default

    <youruser@yourdomain.com>

    Your Atlassian administrator account email

    apiToken

    secret

    From https://id.atlassian.com/manage-profile/security/api-tokens

    Manage API tokens for your Atlassian account

    Note that Postman variables are case-sensitive.

  5. Click Save towards the top right corner.

Create a new collection

  1. Click New, or type Ctrl + N (Windows/Linux) or Cmd + N (MacOS).

  2. Select “Collection”.

  3. Name the collection “Atlassian Cloud User Management”.

  4. Click the “Authorization” tab.
  5. Change Type to “Basic Auth”.

  6. Specify {{apiTokenEmailAddress}} as the Username. The text should be coloured orange, indicating that Postman has recognized a variable has been specified. This can be confirmed by hovering over the variable name.

  7. Specify {{apiToken}} as the Password. The text should be coloured orange, indicating that Postman has recognized a variable has been specified. This can be confirmed by hovering over the variable name.

  8. Click the “Tests” tab.

  9. Enter:

    pm.test("Request successful", function () {
        pm.expect(pm.response.code).to.be.oneOf([200,201,202,204]);
    });


    This allows us to ensure all REST APIs have been made successfully.

  10. Click Save towards the top right corner.

Find organization id

  1. Navigate to admin.atlassian.com.
  2. Select your organization if you have more than one.
  3. Observe your organization id from the URL:
    https://admin.atlassian.com/o//overview
    where the org id is a GUID, for example:
    7d737580-498a-1b1c-kcd1-kdjj1d0bada9

Set up REST API call

  1. Click New, or type Ctrl + N  (Windows/Linux) or Cmd  + N (MacOS).

  2. Select "HTTP".

  3. Name the request "Add User to Team in Atlassian Cloud".

  4. Change the method from GET  to POST .

  5. In the URL, paste:

    {{cloudUrl}}/gateway/api/public/teams/v1/org/<orgId>/teams/{{teamId}}/members/add

    (warning) Note that Postman variables are case-sensitive and must match what is supplied in the attached environment and spreadsheet.

  6. Replace <orgId>  in the URL with the organization id previously obtained.
  7. Click the "Authorization" tab.
  8. Ensure Type is "Inherit auth from parent".

  9. Click the "Body" tab.
  10. Select content type "raw".
  11. In the content space for Body, paste:

    {
      "members": [
        {
          "accountId": "{{accountId}}"
        }
      ]
    }

    (warning) Note that Postman variables are case-sensitive and must match what is supplied in the attached spreadsheet.

  12. Click Save, saving into the "Atlassian Cloud User Management" collection.

Execute Postman Runner 

  1. Change the environment using the environment selector at the top right of Postman, selecting "Atlassian Cloud".

  2. Select Collections in the sidebar.

  3. Select the "Atlassian Cloud User Management" collection.

  4. On the Overview tab, select ▶️ Run towards the top right corner.

  5. Under Run order, ensure there is one and only REST API call - "Add User to Team in Atlassian Cloud".

  6. On the Functional tab, select Run manually.

  7. Click Data.

  8. Navigate to and select the previously prepared csv file from "Map data".

  9. Reduce the number of "Iterations" under Run configuration to 1.

  10. Leave Advanced settings as is.

  11. Click Run Atlassian Cloud User Management.

  12. Check Postman to ensure the runner collection has passed all tests. The run results should show:

    1. "Iterations" and "All tests" to be equivalent in count

    2. Passed (n) where n is the number of iterations

    3. Failed (0)

    4. Skipped (0)

  13. Check admin.atlassian.com to ensure the user in row 2 of the exported list has been made a member of the expected group.

  14. Rerun Postman Runner following the previous steps, with the number of "Iterations" set to the number of rows in the csv file.

Troubleshooting

ErrorComments
401​​Check your credentials.
404
  • Check in the input source csv.
  • Check the case sensitivity of the columns and input variables.
  • Check you are using a comma separated file.
  • Check the Postman console and see what is not being resolved.

References


Last modified on May 21, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.