How to check if a user can administer Confluence in a Connect app

So in my app I need to check whether a user is able to administer Confluence in the cloud. Unfortunately it’s not easy to find in the documentation. Of course you would expect to find something like this in some /user endpoint but if you click through the nested objects it only shows entity type values for targetType.

But if you actually hit the endpoint you will notice that there is another undocumented targetType: application.

...
"operations": [
  {
    "operation": "use",
    "targetType": "application"
  },
  {
    "operation": "administer",
    "targetType": "application"
  },
  {
    "operation": "create_space",
    "targetType": "application"
  }
],
...

So this is exactly what you need when you want to check whether a user is a Confluence administrator. It’s just hidden well. :wink: The respective URLs to use are:

https://{YOUR_URL}.atlassian.net/wiki/rest/api/user/current?expand=operations

or

https://{YOUR_URL}.atlassian.net/wiki/rest/api/user?accountId={USER_ID}&expand=operations

Thanks again @daniel and @mike-scriptlover for the help!

(Posting here so other people will be able to find this via Google in the future :slight_smile:)

8 Likes

Maybe it’s better to use the “Give docs feedback” button on top of the page? That way it is actually documented in the right place!

1 Like

Did that as well but this makes it searchable and also @mike-scriptlover specifically asked me to post it here. :slight_smile:

:speak_no_evil::see_no_evil:

So essentially if

"operation": "administer",
"targetType": "application"

exists then the user is an admin?