Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Check Jira permissions with /rest/api/3/mypermissions

GET /rest/api/3/mypermissions answers whether the calling user holds specific permissions, in the global scope or for a project, work item or comment. The permissions parameter is required and takes permission keys, which GET /rest/api/3/permissions lists.

Endpoints

MethodPathWhat it does
GET/rest/api/3/mypermissionsReturns the caller's permissions for the keys asked.
GET/rest/api/3/permissionsLists all permission keys.

Examples

GET /rest/api/3/mypermissions

Checks four project permissions in project WEB.

curl

curl -G \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  --data-urlencode 'projectKey=WEB' \
  --data-urlencode 'permissions=BROWSE_PROJECTS,CREATE_ISSUES,DELETE_ISSUES,ADMINISTER_PROJECTS' \
  'https://your-domain.atlassian.net/rest/api/3/mypermissions'

Python (requests)

import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/mypermissions',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
    params={'projectKey': 'WEB',
 'permissions': 'BROWSE_PROJECTS,CREATE_ISSUES,DELETE_ISSUES,ADMINISTER_PROJECTS'},
)
print(r.status_code, r.text)

Response: HTTP 200

{
 "permissions": {
  "BROWSE_PROJECTS": {
   "id": "10",
   "key": "BROWSE_PROJECTS",
   "type": "PROJECT",
   "havePermission": true
  },
  "DELETE_ISSUES": {
   "id": "16",
   "key": "DELETE_ISSUES",
   "type": "PROJECT",
   "havePermission": true
  }
 }
}

Response headers

X-Ratelimit-Limit: 350

Sent to Atlassian Cloud on .

GET /rest/api/3/mypermissions

Calls the endpoint with no permissions parameter.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/mypermissions'

Python (requests)

import os
import requests

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

Response: HTTP 400

{
 "errorMessages": [
  "The 'permissions' query parameter is required."
 ],
 "errors": {}
}

Sent to Atlassian Cloud on .

GET /rest/api/3/permissions

Lists the keys the instance knows. Two entries are shown.

curl

curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/permissions'

Python (requests)

import os
import requests

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

Response: HTTP 200

{
 "permissions": {
  "ADD_COMMENTS": {
   "key": "ADD_COMMENTS",
   "name": "Add Comments",
   "type": "PROJECT",
   "description": "Ability to comment on issues."
  },
  "ADMINISTER": {
   "key": "ADMINISTER",
   "name": "Administer Jira",
   "type": "GLOBAL",
   "description": "Create and administer projects, issue types, fields, workflows, and schemes for all projects. Users with this permission can perform most administration tasks, except: managing users, importing data, and editing system email settings."
  }
 }
}

Sent to Atlassian Cloud on .

How it behaves

  • The response is an object keyed by permission key, not an array. Each value holds id, key, name, type, description and havePermission.
  • All four keys asked for (BROWSE_PROJECTS, CREATE_ISSUES, DELETE_ISSUES and ADMINISTER_PROJECTS) came back with havePermission true in project WEB.
  • A request without permissions answered 400 with "The 'permissions' query parameter is required.".
  • /permissions listed 48 permissions, each with key, name, type (PROJECT or GLOBAL) and description, and no havePermission field.

Pitfalls

  • Send permissions every time, even if you only want to check one key.
  • Add projectKey or issueKey for project permissions. Without a context the answer is the global one, where a project permission counts as held if it is held in any project.
  • A true result says the user holds the permission for that context. For issue contexts the spec adds that project permissions based on issue data are evaluated per issue.

Questions and answers

How do I get the list of valid permission keys?

Call GET /rest/api/3/permissions. The call listed 48 keys on this instance, for example BROWSE_PROJECTS and ADD_COMMENTS.

Sources

  1. The Jira Cloud platform REST API v3 (Atlassian Developer)
  2. Get my permissions (Jira REST API v3)

Markdown version · All REST API pages