curl --request POST \
--url https://api.modulex.dev/knowledge-bases/{knowledge_id}/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Organization-ID: <api-key>' \
--data '
{
"query": "<string>",
"top_k": 5,
"min_score": 0,
"filters": {},
"include_content": true,
"include_metadata": true
}
'import requests
url = "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search"
payload = {
"query": "<string>",
"top_k": 5,
"min_score": 0,
"filters": {},
"include_content": True,
"include_metadata": True
}
headers = {
"Authorization": "Bearer <token>",
"X-Organization-ID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Organization-ID': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: '<string>',
top_k: 5,
min_score: 0,
filters: {},
include_content: true,
include_metadata: true
})
};
fetch('https://api.modulex.dev/knowledge-bases/{knowledge_id}/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'top_k' => 5,
'min_score' => 0,
'filters' => [
],
'include_content' => true,
'include_metadata' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Organization-ID: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Organization-ID", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.modulex.dev/knowledge-bases/{knowledge_id}/search")
.header("Authorization", "Bearer <token>")
.header("X-Organization-ID", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.modulex.dev/knowledge-bases/{knowledge_id}/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Organization-ID"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}"
response = http.request(request)
puts response.read_body{
"query": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"top_k": 123,
"total_matches": 123,
"matches": [
{}
]
}{
"detail": "<string>"
}{
"code": "credit_plan_exhausted",
"layer": "credit",
"key": null,
"current": 1000,
"limit": 1000,
"reason": "credit_plan_exhausted"
}{
"code": "quota_exceeded",
"layer": "quota",
"key": "max_knowledge_bases",
"current": 10,
"limit": 10,
"reason": "quota_exceeded"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"code": "rate_limit_exceeded",
"layer": "rate",
"key": "sync_exec",
"current": null,
"limit": 60,
"reason": "rate_limit_exceeded"
}Search a knowledge base
Run a semantic (vector-similarity) search over a knowledge base and return the matching chunks. For ModuleX-managed (modulexai) knowledge bases this reserves one retrieval credit before the embed/search (reject-before-write), so an exhausted org receives a flat DenialEnvelope (402/403/429). BYOK knowledge bases are not billed. Requires the organization admin or owner role.
Note: the backend path parameter is knowledge_base_id; the nav uses knowledge_id (see openQuestions).
curl --request POST \
--url https://api.modulex.dev/knowledge-bases/{knowledge_id}/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Organization-ID: <api-key>' \
--data '
{
"query": "<string>",
"top_k": 5,
"min_score": 0,
"filters": {},
"include_content": true,
"include_metadata": true
}
'import requests
url = "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search"
payload = {
"query": "<string>",
"top_k": 5,
"min_score": 0,
"filters": {},
"include_content": True,
"include_metadata": True
}
headers = {
"Authorization": "Bearer <token>",
"X-Organization-ID": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Organization-ID': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: '<string>',
top_k: 5,
min_score: 0,
filters: {},
include_content: true,
include_metadata: true
})
};
fetch('https://api.modulex.dev/knowledge-bases/{knowledge_id}/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'top_k' => 5,
'min_score' => 0,
'filters' => [
],
'include_content' => true,
'include_metadata' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Organization-ID: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.modulex.dev/knowledge-bases/{knowledge_id}/search"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Organization-ID", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.modulex.dev/knowledge-bases/{knowledge_id}/search")
.header("Authorization", "Bearer <token>")
.header("X-Organization-ID", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.modulex.dev/knowledge-bases/{knowledge_id}/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Organization-ID"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"top_k\": 5,\n \"min_score\": 0,\n \"filters\": {},\n \"include_content\": true,\n \"include_metadata\": true\n}"
response = http.request(request)
puts response.read_body{
"query": "<string>",
"knowledge_base_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"top_k": 123,
"total_matches": 123,
"matches": [
{}
]
}{
"detail": "<string>"
}{
"code": "credit_plan_exhausted",
"layer": "credit",
"key": null,
"current": 1000,
"limit": 1000,
"reason": "credit_plan_exhausted"
}{
"code": "quota_exceeded",
"layer": "quota",
"key": "max_knowledge_bases",
"current": 10,
"limit": 10,
"reason": "quota_exceeded"
}{
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}{
"code": "rate_limit_exceeded",
"layer": "rate",
"key": "sync_exec",
"current": null,
"limit": 60,
"reason": "rate_limit_exceeded"
}Authorizations
User API key: Authorization: Bearer mx_live_*. The X-API-KEY: mx_live_* header is also accepted.
Required organization context for org-scoped endpoints.
Path Parameters
Knowledge base UUID.
Body
Search query.
1Number of results.
1 <= x <= 50Minimum similarity score.
0 <= x <= 1Optional metadata filters.
Include chunk content.
Include chunk metadata.
Was this page helpful?