# Query knowledge base details

Read the complete metadata of a knowledge base, including associated assets, index status, and versions.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/knowledge-bases/{knowledge_base_id}
```

## Before you call

First [query the knowledge base list](list-agent-knowledge-bases.md) to obtain the knowledge base ID. 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 the `X-Workspace-ID` Header and also as `workspace_id` in the path.
- `$KNOWLEDGE_BASE_ID`: ID of the knowledge base to be queried.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/knowledge-bases/$KNOWLEDGE_BASE_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Current workspace ID, must be consistent with `X-Workspace-ID`. |
| `knowledge_base_id` | string | Yes | The ID of the knowledge base to be queried. |

## Successful response

Returns `200` on success. `data` is knowledge base metadata.

```json
{
  "code": 0,
  "data": {
    "id": "kb_01",
    "workspace_id": "ws_01",
    "name": "产品文档",
    "description": "已审核的产品资料",
    "status": "active",
    "source_type": "catalog_resource",
    "catalog_asset_refs": [
      {
        "type": "catalog",
        "id": "cat_01",
        "role": "source"
      }
    ],
    "tags": ["产品", "文档"],
    "owner_user_id": "user_01",
    "visibility": "workspace",
    "index_status": "ready",
    "last_indexed_at": "2026-08-18T01:00:00Z",
    "version": 2,
    "labels": {
      "department": "product"
    },
    "created_by": "user_01",
    "updated_by": "user_01",
    "created_at": "2026-08-18T01:00:00Z",
    "updated_at": "2026-08-18T02:00:00Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.id` | string | Knowledge base ID. |
| `data.workspace_id` | string | ID of the workspace to which it belongs. |
| `data.name` | string | Name and description; will not be returned if no description is set. |
| `data.description` | string | Name and description; will not be returned if no description is set. |
| `data.status` | string | Knowledge base status and source type. |
| `data.source_type` | string | Knowledge base status and source type. |
| `data.catalog_asset_refs` | object[] | Associated assets; not returned if not set. Each item can contain `type`, `id`, `uri`, `version`, `role`, and `config`. |
| `data.default_retrieval_profile_ref` | string | Default retrieval configuration reference; does not return if not set. |
| `data.tags` | string[] | Label; does not return if not set. |
| `data.owner_user_id` | string | Owner user ID; not returned if not set. |
| `data.visibility` | string | Visible range and index status. |
| `data.index_status` | string | Visible range and index status. |
| `data.last_indexed_at` | string | Recent index time and error message; not returned if not set. |
| `data.last_index_error` | string | Recent index time and error message; not returned if not set. |
| `data.version` | integer | Resource version. |
| `data.labels` | object | Extended tags, comments, and metadata; not returned if not set. |
| `data.annotations` | object | Extended tags, comments, and metadata; not returned if not set. |
| `data.metadata` | object | Extended tags, comments, and metadata; not returned if not set. |
| `data.created_by` | string | Creator and last updater ID; not returned if not set. |
| `data.updated_by` | string | Creator and last updater ID; not returned if not set. |
| `data.created_at` | string | Creation and last update times, in RFC 3339 format. |
| `data.updated_at` | string | Creation and last update times, in RFC 3339 format. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.


## Error response

```json
{
  "code": 3,
  "message": "knowledge base not found"
}
```

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter is invalid.
  - Check the workspace ID and knowledge base ID and do not use path separators in the ID.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `404`
  - `3`（`NOT_FOUND`）
  - The knowledge base does not exist in the current workspace.
  - Check out `knowledge_base_id`, or consult the knowledge base list first.
* - `503`
  - `15`（`UNAVAILABLE`）
  - The knowledge base service is temporarily unavailable.
  - Try again later.
```

## Follow-up operations

When metadata needs to be modified, call [Update knowledge base](update-agent-knowledge-base.md).
