Skip to content

Query the knowledge base

post/query-knowledge-base/{chatbotId}
Any keyUses credits

This operation fetches segments pertinent to generating responses. Designed for seamless chatbot integration with the GPTs store, this API endpoint allows users to supply relevant document fragments to the GPTs. As with the /get-confidence-score endpoint, results are cached by query for efficiency.

Credit Cost: Each query costs 0.5 message credits. If reranking runs, the total cost is 1.0 message credit (0.5 base + 0.5 reranking); a cached result costs 0.5 even with reranking enabled. Requests are rejected if the available credits are insufficient.

Path parameters

Required
chatbotIdstring
The unique identifier allocated to the chatbot.

Request body

Sending 1 of 2 fields
Required
querystring
The text used to search the knowledge base by vector (cosine) similarity.

Only these fields are sent (application/json).

Try it · POST /query-knowledge-base/{chatbotId}
curl 'https://api.chat-data.com/api/v2/query-knowledge-base/6650f1c2a9e4b83d2c7a1f05' \  -H "Authorization: Bearer $CHAT_DATA_API_KEY" \  -H 'Content-Type: application/json' \  -d '{  "query": "What are your opening hours?"}'
Loading…

Responses

Successful response. The body is a JSON array of matching chunks, without a status field.

Content type: application/json

FieldDescription
[].sourcestringThe name or URL of the source (document filename, website URL, etc.).
[].typestringThe data source type of the chunk (e.g. website, text/pdf, text/csv, product, video, notion).
[].snippetstringThe text content of the chunk.
[].relavant_scorestringThe similarity score of the chunk as a string with two decimal places (the field name is spelled relavant_score).

Example

[  {    "source": "https://www.example.com/support/opening-hours",    "type": "website",    "snippet": "Our support team is available Monday to Friday, 9am to 6pm EST. Outside these hours you can email [email protected].",    "relavant_score": "0.87"  }]

Last updated October 14, 2026