Skip to main content
POST
/
api
/
knowledge
/
search
curl -X POST https://api.example.com/api/knowledge/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "How do I configure authentication?",
    "projectId": "proj_123",
    "topK": 5,
    "minScore": 0.7,
    "searchType": "semantic"
  }'
{
  "success": true,
  "documents": [
    {
      "id": "chunk_abc123",
      "content": "To configure authentication, navigate to Settings > Security...",
      "score": 0.89,
      "metadata": {
        "fileName": "setup-guide.pdf",
        "fileType": "pdf",
        "pageNumber": 12,
        "chunkIndex": 5
      }
    },
    {
      "id": "chunk_def456",
      "content": "Authentication can be enabled using OAuth 2.0 or API keys...",
      "score": 0.82,
      "metadata": {
        "fileName": "api-reference.md",
        "fileType": "markdown",
        "section": "Authentication"
      }
    }
  ],
  "message": "Found 2 relevant documents"
}

Request Body

query
string
required
Search query text
projectId
string
required
Project ID to search within
topK
number
default:5
Maximum number of results to return
minScore
number
Minimum similarity score threshold (0-1)
searchType
string
Search algorithm type
  • semantic - Pure vector similarity search
  • mrr - Maximal Marginal Relevance (diverse results)
  • hybrid - Combines semantic and keyword search
alpha
number
Balance between semantic and keyword search in hybrid mode (0-1)
  • 0 = Pure keyword search
  • 1 = Pure semantic search
  • 0.5 = Equal weight (default)

Response

success
boolean
Whether the search was successful
documents
array
Array of matching document chunks
message
string
Status message or error details
curl -X POST https://api.example.com/api/knowledge/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "How do I configure authentication?",
    "projectId": "proj_123",
    "topK": 5,
    "minScore": 0.7,
    "searchType": "semantic"
  }'
{
  "success": true,
  "documents": [
    {
      "id": "chunk_abc123",
      "content": "To configure authentication, navigate to Settings > Security...",
      "score": 0.89,
      "metadata": {
        "fileName": "setup-guide.pdf",
        "fileType": "pdf",
        "pageNumber": 12,
        "chunkIndex": 5
      }
    },
    {
      "id": "chunk_def456",
      "content": "Authentication can be enabled using OAuth 2.0 or API keys...",
      "score": 0.82,
      "metadata": {
        "fileName": "api-reference.md",
        "fileType": "markdown",
        "section": "Authentication"
      }
    }
  ],
  "message": "Found 2 relevant documents"
}