# Get All Workspaces

## Overview

Get the workspaces from the end system that the integration user has access to.

> **Note**: Return the empty list if the end system does not have the Workspaces' structure.

## API URI

This is the URI OpsHub will execute to call this API:

```bash
GET: /mbse/api/1.0/workspaces?
    startIndex=<startIndex>
    maxResults=<maxResults>
```

## URI Parameters

| Name       | In    | Required | Type    | Description                                                                               |
| ---------- | ----- | -------- | ------- | ----------------------------------------------------------------------------------------- |
| startIndex | Query | True     | Integer | Start index from which list of workspaces should be returned                              |
| maxResults | Query | True     | Integer | Maximum number of workspaces to be returned by custom connector, starting from startIndex |

## Response Payload

```json
[
  {
    "id": "unique identifier",
    "name": "project name",
    "parentWorkSpaceId": "parent workspace id"
  }
]
```

| Name              | Type              | Required | Description                                                                                            |
| ----------------- | ----------------- | -------- | ------------------------------------------------------------------------------------------------------ |
| id                | Integer or String | True     | Id or internal name of the workspace                                                                   |
| name              | String            | True     | Display name of the workspace                                                                          |
| parentWorkSpaceId | String            | False    | If end system supports workspace hierarchy, set the id or internal name of the direct parent workspace |

## Examples

### Flat workspace list

**Example 1:**

```json
[
  {
    "id": "1",
    "name": "Sample Workspace",
    "parentWorkSpaceId": ""
  },
  {
    "id": "2",
    "name": "Demo Workspace",
    "parentWorkSpaceId": ""
  }
]
```

### Example 2

```json
[
  {
    "id": "SAMP",
    "name": "Sample Workspace",
    "parentWorkSpaceId": ""
  },
  {
    "id": "DEMO",
    "name": "Demo Workspace",
    "parentWorkSpaceId": ""
  }
]
```

### Workspace hierarchy

```json
[
  {
    "id": "ws-11",
    "name": "Main Child Workspace",
    "parentWorkSpaceId": "ws-1"
  },
  {
    "id": "ws-12",
    "name": "Sample Workspace",
    "parentWorkSpaceId": "ws-1"
  },
  {
    "id": "ws-21",
    "name": "Demo Workspace",
    "parentWorkSpaceId": "ws-2"
  },
  {
    "id": "ws-22",
    "name": "Trial Workspace",
    "parentWorkSpaceId": "ws-3"
  }
]

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://opstech.gitbook.io/opstech-docs/7.223/mbse-connector-sdk-index/mbse-sdk-connector-apis/metadata-apis/workspaces-list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
