Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Bulk user lookup and groups in the Jira REST API

GET /rest/api/3/user/bulk resolves several accountId values in one paged call. GET /rest/api/3/user/groups lists the groups of one user as name and groupId pairs. On the single-user lookup the groups are collapsed to a count unless expand=groups is set.

Endpoints

MethodPathWhat it does
GET/rest/api/3/user/bulkReturns users for one or more accountId values, paged.
GET/rest/api/3/user/groupsReturns the groups a user belongs to.
GET/rest/api/3/userReturns one user and can expand groups and application roles.

Examples

GET /rest/api/3/user/bulk

Looks up one accountId. The response is a paged envelope with a values array.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'accountId=<accountId>' \
  'https://your-domain.atlassian.net/rest/api/3/user/bulk'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/user/bulk',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'accountId': '<accountId>'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "maxResults": 10,
 "startAt": 0,
 "total": 1,
 "isLast": true,
 "values": [
  {
   "accountType": "atlassian",
   "displayName": "<display name>",
   "active": true
  }
 ]
}

Response headers

X-Ratelimit-Limit: 350

Sent to Atlassian Cloud on .

GET /rest/api/3/user/groups

Lists the groups of the caller. Only names are kept in the excerpt.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'accountId=<accountId>' \
  'https://your-domain.atlassian.net/rest/api/3/user/groups'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/user/groups',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'accountId': '<accountId>'},
)
print(r.status_code, r.text)

Response: HTTP 200

[
 {
  "name": "org-admins"
 },
 {
  "name": "loom-users-your-domain"
 },
 {
  "name": "confluence-admins-your-domain"
 }
]

Sent to Atlassian Cloud on .

GET /rest/api/3/user

Reads the caller without expand. groups has a size and an empty items array.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'accountId=<accountId>' \
  'https://your-domain.atlassian.net/rest/api/3/user'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/user',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'accountId': '<accountId>'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "displayName": "<display name>",
 "groups": {
  "size": 6,
  "items": []
 },
 "applicationRoles": {
  "size": 1,
  "items": []
 },
 "expand": "groups,applicationRoles"
}

Sent to Atlassian Cloud on .

GET /rest/api/3/user

The same call with expand=groups,applicationRoles. The group items are filled in.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'accountId=<accountId>' \
  --data-urlencode 'expand=groups,applicationRoles' \
  'https://your-domain.atlassian.net/rest/api/3/user'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/user',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'accountId': '<accountId>', 'expand': 'groups,applicationRoles'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "displayName": "<display name>",
 "groups": {
  "size": 6,
  "items": [
   {
    "name": "confluence-admins-your-domain"
   },
   {
    "name": "confluence-users-your-domain"
   },
   {
    "name": "jira-users-your-domain"
   }
  ]
 },
 "applicationRoles": {
  "size": 1
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • The bulk response has the paged shape startAt, maxResults, total, isLast and values. The self link shows maxResults=10, so the default page size there is 10.
  • /user/groups returned a plain array of objects with name, groupId and self, six groups for the caller.
  • GET /user without expand reported groups.size 6 and items []. With expand=groups,applicationRoles the six items were present.

Pitfalls

  • A group name can change. Store groupId when you need a stable reference, which is also the spec's advice for visibility settings.
  • groups.size can be non-zero while items is empty. That is the collapsed form, not an account without groups.
  • Pass accountId once per user in the bulk call and page through values until isLast is true.

Questions and answers

How do I get a user's groups without a second request?

Call GET /rest/api/3/user with expand=groups. The items are then filled in, as the expanded run above shows.

Sources

  1. The Jira Cloud platform REST API v3 (Atlassian Developer)
  2. Bulk get users (Jira REST API v3)

Markdown version · All REST API pages