# Get the list of your workspaces for v3

**URL:** <https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v3/2027>\
**Category:** Developer\
**Tags:** api\
**Created:** [July 26, 2022, 6:52pm UTC](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v3/2027 "2022-07-26T18:52:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Garrett](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@Tom\_Garrett](https://community.bluescape.com/u/Tom_Garrett)\
**Post date:** [July 26, 2022, 6:52pm UTC](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v3/2027/1 "2022-07-26T18:52:01Z")

</div>

**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 [v3 REST APIs](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v3/2027#implementation-using-rest-apis-1) and for [v3 GraphQL APIs](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v3/2027#implementation-using-graphql-apis-5). You can also see the example for [v2 REST APIs](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v2/2033).

All API endpoints share the same base URL:

`https://api.apps.us.bluescape.com`

After you receive the authentication token, you can get a list of all the workspaces you can access.

## Implementation using REST APIs

| **Endpoint** | /v3/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 cURL, Node.js, and Python.

> **cURL**
>
> ````auto
> curl --location --request GET 'https://api.apps.us.bluescape.com/v3/users/me/workspaces' \
> --header 'Authorization: Bearer <SET_TOKEN>' ```
> 
> ````

> **Node.js**
>
> ```auto
> // 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 = 'https://api.apps.us.bluescape.com';
> const api_version = 'v3';
> 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);
> });
>     
> 
> ```

> **Python**
>
> ```auto
> # 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 = "https://api.apps.us.bluescape.com"
> 
> # Get all the workspaces for your user
> API_version = 'v3'
> 
> 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)
> 
> ```

### 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

```auto
{
  "workspaces": [
      {
          "id": "jb37zzmsAvin16ti2A-9",
          "name": "test-workspace",
          "description": "",
          "isPublic": true,
          "defaultRoleId": "JuTasisnG_LWZ6VyE-d5",
          "organizationId": "ugNVBeehXBSc8wV3BzTG",
          "contentUpdatedAt": null,
          "createdAt": "2021-02-02T00:30:38.000Z",
          "updatedAt": "2021-02-25T19:51:12.000Z"
      }
  ],
  "prev": null,
  "next": null
}

```

## Implementation using GraphQL APIs

| Query | me |
| --- | --- |
| Comments | You do not need to know the userId to get this list of workspaces of the user. |

### Example Query:

```auto
query getMyWorkspaces{
  me {
   workspaces {
    totalItems
    results {
      name
      description
      isPublic
      owner {email firstName lastName}
    }
  }
  }
}

```

### Code sample

See below for full code examples of this implementation in cURL, Node.js, and Python.

> **cURL**
>
> ```auto
> curl --location --request POST 'https://api.apps.us.bluescape.com/v3/graphql' \
> --header 'Authorization: Bearer <SET_TOKEN>' \
> --header 'Content-Type: application/json' \
> --data-raw '{"query":"query getMyWorkspaces{\n me {\n workspaces {\n totalItems\n results {\n name\n description\n isPublic\n owner {email firstName lastName}\n }\n }\n }\n}","variables":{}}'
> 
> ```

> **Node.js**
>
> ```auto
> const axios = require('axios');
> 
> const url = "https://api.apps.us.bluescape.com/v3/graphql"
> const token = "<SET_TOKEN>"
> const query = `query getMyWorkspaces{
> me {
> workspaces {
> totalItems
> results {
> name
> description
> isPublic
> owner {email firstName lastName}
> }
> }
> }
> }`
> const getWorkspaces = async () => {
> try {
> const response = await axios.post(url,
> {query: query}, 
> {headers: {"Authorization": "Bearer " + token}})
>         
> answerData = JSON.stringify(response.data);
> console.log(answerData);
> return response
> }
> catch(error) {
> console.error(error)
> }
> }
> 
> getWorkspaces();
> 
> ```

> **Python**
>
> ```auto
> import requests
> import pprint
> 
> url = "https://api.apps.us.bluescape.com/v3/graphql"
> token = "<SET_TOKEN>"
> query = """
> query getMyWorkspaces{
> me {
> workspaces {
> totalItems
> results {
> name
> description
> isPublic
> owner {email firstName lastName}
> }
> }
> }
> }
> """
> def makeQuery():
> 
> response = requests.post(url, 
> headers={"Authorization": "Bearer " + token
> },
> json={'query': query})
> 
> return response.json()
> 
> if __name__ == " __main__":
> response = makeQuery()
> pprint.pprint(response)
> 
> ```

### Output

```auto
{
  "data": {
    "me": {
      "workspaces": {
        "totalItems": 2,
        "results": [
          {
            "name": "workspace 1",
            "description": "",
            "isPublic": true,
            "owner": {
              "email": "littlejohnny@someplace.org",
              "firstName": "Little",
              "lastName": "Johnny"
            }
          },
          {
            "name": "workspace 2 - meetings",
            "description": "For our meetings",
            "isPublic": true,
            "owner": {
              "email": "jopsephusmiller@someplace.org",
              "firstName": "Josephus",
              "lastName": "Miller"
            }
          }
        }
    }
  }
}

```

 

> # Where to Next?
> 
> - [Get the list of your workspaces for v2](https://community.bluescape.com/t/get-the-list-of-your-workspaces-for-v2/2033)
> - [Bluescape API Guides](https://community.bluescape.com/t/bluescape-api-guides-landing-page/2020)
> - [Bluescape API Overview](https://community.bluescape.com/t/wip-bluescape-api-overview/2021/2)
> - [Latest Developer topics](https://community.bluescape.com/c/developer/14)
> 
> **Not what you were looking for? Reply below or [Search](https://community.bluescape.com/search) the community and discover more Bluescape.**
