Get the list of your workspaces for v2
Objective: get a list of all Workspaces you can access. You do not need to know your userId to perform this operation. From this list you can retrieve the workspace IDs to use on other APIs that require you to have the Workspace ID. This is a good test to verify the functionality of your Access Token.
This page contains the implementation details for v2 REST APIs. You can also see the example for v3 APIs
All API endpoints share the same base URL:
After you receive the authentication token, you can get a list of all the workspaces you can access.
Implementation using REST APIs v2
Endpoint | /v2/users/me/workspaces |
Method | GET |
Comments | You do not need to know the userId to get this list of workspaces of the user. |
Code sample
See below code samples in Python and Node.js.
# Python Code (python 3.5+) import requests import pprint ''' Required modules: requests 2.22.0 ''' # Get the list of workspaces the user account associates to the Authentication Token can access token = '<SET_TOKEN>' if __name__ == "__main__": portal = "" # Get all the workspaces for your user API_version = 'v2' API_endpoint = '/' + API_version + '/users/me/workspaces' the_request = requests.get( portal + API_endpoint, headers={"Authorization": "Bearer " + token} ) # format answer to json json_response = the_request.json() # By default we get the first 25 workspaces # added to format display of json output pprint.pprint(json_response)
// NodeJS var axios = require('axios'); /* How to run: node this_script_name.js Requires "axios" module (0.19.0), run: npm install axios website: https://github.com/axios/axios */ const token = '<SET_TOKEN>'; const portal = ''; const api_version = 'v2'; const api_endpoint = '/users/me/workspaces'; request_values = { method: 'GET', url: portal + '/' + api_version + api_endpoint, headers : { 'Authorization': "Bearer " + token, 'Content-Type' : 'application/json' } }; axios(request_values) .then(function (response) { if (response.status == 200) { console.log("Success"); console.log(response.data); } }) .catch (function (error) { console.log('Error: ' + error.message); });
curl --location --request GET '/v2/users/me/workspaces' \ --header 'Authorization: Bearer <SET_TOKEN>'
OUTPUT
What you should get: JSON with the list of the first 25 workspaces your user has access to.
Element | Json | Comments |
Workspace ID | ['workspaces'][N]['id'] | where N is the N-th workspace in the list. |
Workspace name | ['workspaces'][N]['name'] | where N is the N-th workspace in the list. |
Output Json sample
{'limit': 25, 'offset': 0, 'paging': {'next': '/v2/users/me/workspaces?offset=25&limit=25', 'prev': None, 'self': '/v2/users/me/workspaces?offset=0&limit=25'}, 'size': 25, 'total': 121, 'workspaces': [{'active_users_count': 0, 'created_at': '2016-11-18T01:34:10.000Z', 'default_role_uid': None, 'description': '', 'favorite': 0, 'has_meeting': False, 'name': 'Hello', 'organization': {'default_public_workspace_role_uid': 'mmFwoDayeaLnPGx3QTcZ', 'name': 'Bluescape', 'uid': '2M-EiUhza9MZgrw2CJ31'}, 'organization_uid': '2M-EiUhza9MZgrw2CJ31', 'public': True, 'publish_state': 'published', 'publish_state_at': '2016-11-18T01:35:38.000Z', 'published_at': '2016-11-18T01:35:38.000Z', 'published_url': 'https://viewer.bluescape.com/9r1UGKtsoxRfv_x3kd-E', 'uid': '9r1UGKtsoxRfv_x3kd-E', 'updated_at': '2019-10-07T21:59:03.000Z', 'users_count': 2, 'workspace_owner': {'avatar_url': None, 'created_at': '2016-06-27T23:41:14.000Z', 'email': '[email protected]', 'first_name': 'Indiana', 'industry': 'Other - not listed', 'last_name': 'Jones', 'locked_at': None, 'phone_number': '4085553848', 'title': None, 'uid': 'JnPiG6qd2EtFCjipWRE1', 'updated_at': '2019-02-04T11:11:32.000Z'}, 'workspace_role': {'can_at_mention': True, 'can_comment': True, 'can_download_assets': True, 'can_edit_workspace_content': True, 'can_list_collaborators': True, 'can_send_message': True, 'can_send_to_wall': True, 'can_view_workspace_content': True, 'can_view_workspace_settings': True, 'description': 'Editor can view workspace ' 'settings, can view, ' 'comment and edit ' 'workspaces content, and ' 'can view collaborators', 'display_order': 3, 'is_custom': False, 'name': 'Editor', 'type': 'user', 'uid': 'mmFwoDayeaLnPGx9QTcZ'}}, {'active_users_count': 0, 'created_at': '2016-12-12T20:32:57.000Z', 'default_role_uid': None,
... ...
If you have any questions or comments, please contact us in the Bluescape Community site.