Skip to main content

Query Knowledge Base

Perform semantic search on a knowledge base using vector similarity.

POST /api/v1/knowledge-bases/:id/query

Required Scopes: knowledge-bases:read, knowledge-bases:query

Request

Path Parameters

ParameterTypeDescription
idstringKnowledge Base ID

Body Parameters

ParameterTypeRequiredDefaultDescription
querystringYes-Search query text
top_knumberNo5Number of results to return (1-20)

Example

curl -X POST "https://api.flowmaestro.ai/v1/knowledge-bases/kb_abc123/query" \
-H "X-API-Key: fm_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"query": "How do I reset my password?",
"top_k": 5
}'

Response

{
"data": {
"results": [
{
"id": "chunk_001",
"content": "To reset your password, go to Settings > Security > Change Password. Enter your current password and then enter your new password twice to confirm...",
"document_id": "doc_abc",
"document_name": "User Guide.pdf",
"score": 0.92,
"metadata": {
"page": 15,
"section": "Account Settings"
}
},
{
"id": "chunk_002",
"content": "If you've forgotten your password, click 'Forgot Password' on the login page. We'll send a reset link to your registered email address...",
"document_id": "doc_def",
"document_name": "FAQ.md",
"score": 0.87,
"metadata": {}
}
],
"query": "How do I reset my password?",
"top_k": 5
},
"meta": {
"request_id": "...",
"timestamp": "..."
}
}

Response Fields

FieldDescription
idUnique chunk identifier
contentText content of the chunk
document_idID of the source document
document_nameName of the source document
scoreSimilarity score (0-1, higher is more similar)
metadataAdditional metadata from the document

Errors

StatusCodeDescription
404resource_not_foundKnowledge base not found
400validation_errorInvalid query parameters