# Semantic Search over Knowledge Documents

`POST /api/knowledge/documents/hub-query`

### Overview
Embeds the query and searches the Qdrant chunks of processed documents the caller may view. Results are ordered by cosine similarity (no reranker).

### Authentication & Headers
- **Auth**: Bearer Token
- **Required Header**: `API-Version: 1`

### Parameters & Request Body Fields
- **`query`** *(string, required)*: Natural language question.
- **`top_k`** *(integer, optional, default: 5, max: 20)*: Maximum returned chunks.
- **`threshold`** *(number, optional, default: 0.35)*: Minimum similarity.
- **`filters.document_ids`** *(array, optional)*: Restrict the search to these documents.

## Request body

Content type: `application/json`

```json
{}
```

## Responses

### 200 — Matching chunks

### 400 — Bad Request - The request parameters or headers are invalid (e.g. unsupported API-Version).

### 401 — Unauthorized - Missing, invalid, or expired JWT Bearer token.

### 403 — Forbidden - Insufficient role permissions or resource access denied by RBAC policy.

### 404 — Not Found - The requested resource ID was not found.

### 422 — Empty query or invalid top_k/threshold

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | object[] | no |  |
| `detail[].loc` | string | integer[] | yes |  |
| `detail[].msg` | string | yes |  |
| `detail[].type` | string | yes |  |
| `detail[].input` | object | no |  |
| `detail[].ctx` | object | no |  |

```json
{
  "detail": [
    {
      "loc": [
        null
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

### 503 — Search backend temporarily unavailable

## Example

```bash
curl -X POST "$PINTER_URL/api/knowledge/documents/hub-query" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```
