# Browse catalogs, databases, volumes and tables

Returns hierarchical navigation data for catalogs, databases, volumes, and tables accessible in the current workspace.

```text
POST https://moi.matrixorigin.cn/newmoi/catalog/tree
```

## Preparation before calling

Prepare a personal access token and target workspace ID that has access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/tree" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "include_table_leaves": true
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `include_table_leaves` | boolean | No | Whether to include table leaf nodes in the tree. |

## Successful response

Returns `200` on success. The result contains only nodes that are readable by the current identity.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "tree": [
      {
        "id": "1",
        "type": "catalog",
        "name": "sales",
        "display_name": "sales",
        "description": "销售数据",
        "reserved": false,
        "node_list": [
          {
            "id": "2",
            "type": "database",
            "name": "orders",
            "description": "",
            "reserved": false,
            "node_list": []
          }
        ],
        "allowed_actions": ["catalog.read"]
      }
    ]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.tree` | object[] | Root node list; empty array when there are no readable resources. |
| `data.tree[].id` | string | Node ID. |
| `data.tree[].type` | string | Node type: `catalog`, `database`, `volume`, or `table`. |
| `data.tree[].name` | string | Node name. |
| `data.tree[].display_name` | string | Node display name; returned if there is a value. |
| `data.tree[].description` | string | Node description. |
| `data.tree[].display_description` | string | Node display description; returned if there is a value. |
| `data.tree[].reserved` | boolean | Whether it is a reserved node. |
| `data.tree[].is_pub` | boolean | Whether it is a publishing node; returned when applicable. |
| `data.tree[].is_sub` | boolean | Whether it is a subscribing node; returned when applicable. |
| `data.tree[].node_list` | object[] | Child node, the fields are the same as the parent node. |
| `data.tree[].allowed_actions` | string[] | The operations that the current identity can perform on this node. |
| `data.tree[].has_workflow_target_ref` | boolean | Whether it is referenced by the workflow as a target; returned if there is a value. |
| `data.tree[].trigger_binding` | object | Binding information of volumes and workflow triggers; returned if there is a value. |
| `data.tree[].trigger_binding.bound` | boolean | Whether there is a trigger binding. |
| `data.tree[].trigger_binding.trigger_id` | integer | Trigger ID. |
| `data.tree[].trigger_binding.workflow_id` | string | Association workflow ID. |
| `data.tree[].trigger_binding.workflow_name` | string | The name of the associated workflow. |
| `data.tree[].trigger_binding.workflow_version_id` | string | The associated workflow version ID. |

In this document, `[]` after a type means an array; for example, `object[]` is an array of objects. In field paths, `[]` means each item in an array; for example, `data.tree[].id` is the `id` field of each item in `data.tree`.

## 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`
  - The request body is not valid JSON.
  - Check the request JSON.
* - `401`
  - `ErrUnauthorized`
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `500`
  - `ErrServer`
  - The server failed to read the directory tree.
  - Try again later.
```

## Follow-up operations

After completion, you can return to [Query file products](list-file-artifacts.md).
