---
orphan: true
---

# Query the workspace name

Query the name by the workspace ID in an existing data sharing relationship.

```text
POST https://moi.matrixorigin.cn/newmoi/data-share/workspace-names
```

## Preparation before calling

Prepare a personal access token with access to the target workspace, the target workspace ID, and a list of workspace IDs to query.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Current workspace ID, passed through `X-Workspace-ID` Header.
- `$TARGET_WORKSPACE_ID`: The workspace ID whose name is to be queried.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/data-share/workspace-names" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": ["'"$TARGET_WORKSPACE_ID"'"]
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `ids` | string[] | Yes | A list of workspace IDs to query for names. |

`[]` after a type means an array. For example, `string[]` is an array of strings.

## Successful response

Returns `200` and the resolvable workspace name on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "workspaces": [
      {
        "id": "ws-02",
        "name": "分析工作区"
      }
    ]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.workspaces` | array | A list of resolvable workspaces. |
| `data.workspaces[].id` | string | Workspace ID. |
| `data.workspaces[].name` | string | Workspace name. |

In field paths, `[]` means each item in an array. For example, `data.workspaces[].id` is the `id` field of each item in `data.workspaces`.

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - Invalid request body format or workspace ID list.
  - Check `ids`.
* - `403`
  - `ErrPermissionDenied`
  - The current identity is not a valid member of the current workspace.
  - Use credentials that have workspace access.
* - `500`
  - `ErrServer`
  - The server failed to resolve the workspace name.
  - Try again later.
```
