Skip to main content

User roles

There are three pre-defined roles within workspaces:

  • Owner: can perform all actions in the workspace
  • Editor: can perform all actions excluding deleting of a workspace
  • Viewer: can view the workspace

These user roles can be assigned to users in a workspace. Once a role has been assigned it can be replaced or removed. Users can also retrieve user roles, the role of a particular user, and their own role if applicable.

Listing user roles

GET https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users

To list all user roles for a workspace, perform a GET request:

import requests

response = requests.get(
f"https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users",
headers={ "Authorization": "Bearer [yourtokenhere]" },
)
print(response.json())

Filtering

You can specify a user ID to filter by, to return a user role for a specific user.

import requests

response = requests.get(
f"https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users?filter[user_id]=<user_id>",
headers={ "Authorization": "Bearer [yourtokenhere]" },
)
print(response.json())

Retrieving your role

You can retrieve your own user role. This is done by performing a GET request to the current-user-role route for a given workspace:

import requests

response = requests.get(
f"https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/current-user-role",
headers={ "Authorization": "Bearer [yourtokenhere]" },
)
print(response.json())

Assigning a role to a user

POST https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users

You can assign a role to a user with a POST request. You may modify roles for a user up to and including the role that your account has. For example, if you are an "editor", you can add or remove the "viewer" or "editor" role on another user, but you cannot add or remove the "owner" role.

import requests

response = requests.post(
f"https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users",
json={
"role": "editor",
"user_id": "71aa0a41-6177-4248-94e5-78ba4ebf9d7e",
},
headers={ "Authorization": "Bearer [yourtokenhere]" },
)
print(response.json())

Removing a role from a user

DELETE https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users/<user_id>

To remove a role for a user, perform a DELETE request:

import requests

response = requests.delete(
f"https://<service_host>/workspace/orgs/<org_id>/workspaces/<workspace_id>/users/<user_id>",
headers={ "Authorization": "Bearer [yourtokenhere]" },
)
print(response)

© Seequent, The Bentley Subsurface Company