GET
/
api
/
knowledgebases
/
{knowledgebaseId}
/
query
Query Chunks
curl --request GET \
  --url https://app.pathors.com/api/knowledgebases/{knowledgebaseId}/query \
  --header 'x-api-key: <x-api-key>'
{
  "id": "<string>",
  "content": "<string>",
  "contentLength": 123,
  "isEnabled": true
}

Query Chunks

Retrieves relevant chunks from a specific knowledgebase based on a semantic search query.

Endpoint

GET /api/knowledgebases/{knowledgebaseId}/query

Path Parameters

knowledgebaseId
string
required
The unique identifier of the knowledgebase to query

Headers

x-api-key
string
required
Your project API key for authentication

Query Parameters

q
string
required
The search query to match against the knowledgebase content
topK
number
Maximum number of results to return. Defaults to 5
scoreThreshold
number
Minimum relevance score for chunks to be included. Defaults to 0.3
Example request:
GET /api/knowledgebases/kb_abc123/query?q=search_term&topK=5&scoreThreshold=0.3

Response

Returns an array of chunks that match the query, ordered by relevance.
id
string
Unique identifier for the chunk
content
string
The content of the chunk
contentLength
number
Length of the chunk content
isEnabled
boolean
Whether the chunk is enabled for search
Example response:
[
  {
    "id": "chunk_abc123",
    "content": "The product features include real-time analytics...",
    "contentLength": 82,
    "isEnabled": true
  }
]

Error Responses

Status CodeDescription
400Invalid query parameters or missing knowledgebase ID
401Invalid API key
404Knowledgebase not found or access denied
500Internal server error

How It Works

  1. The knowledgebase is validated to ensure it exists and belongs to your project
  2. The query text is converted into embeddings using the same model as the knowledgebase
  3. The embeddings are used to perform semantic similarity search against stored chunks
  4. The most relevant chunks are returned, ordered by similarity score
  5. Results are limited to the specified topK parameter

Usage Notes

  • Queries are processed using semantic search, not exact text matching
  • Results are returned in order of relevance to the query
  • The response includes the most relevant chunks from the specified knowledgebase only
  • Use the topK parameter to control the number of results returned
  • Consider the context when formulating queries for best results
  • The knowledgebase must belong to the project associated with your API key