Making API calls
Before you call a Knowledge Hub API, generate a JWT. For more information, refer to Authenticating APIs.
To call a Knowledge Hub API:
- Send the JWT as a Bearer token in the
Authorizationheader. - Use the base URL for your environment from the Introduction.
- Send request bodies as JSON and set the
Content-Typeheader toapplication/json.
Retrieve knowledge chunks
Use the Retrieve API to search a knowledge base. Send a POST request to /api/v1/knowledge-bases/{knowledge_base_id}/retrieve.
The request body has the following fields:
query(required): The text to search for. Maximum length is 10,000 characters.top_k(optional): The number of results to return, from 1 to 100.retrieval_mode(optional): The search method, such assemantic,lexical, orhybrid.filters(optional): Key-value pairs that limit the results to matching content.
The following example uses the Prod (US) environment:
curl -X POST "https://retrieve-api.prod.kh.boomi.com/api/v1/knowledge-bases/{knowledge_base_id}/retrieve" \
-H "accept: application/json" \
-H "Authorization: Bearer {JWT}" \
-H "Content-Type: application/json" \
-d '{"query": "What is the parental leave policy?", "retrieval_mode": "hybrid", "top_k": 5}'
Replace {knowledge_base_id} with the ID of your knowledge base and {JWT} with your token.
Python example
import requests
KNOWLEDGE_BASE_ID = "your-knowledge-base-id"
JWT = "your-jwt"
url = f"https://retrieve-api.prod.kh.boomi.com/api/v1/knowledge-bases/{KNOWLEDGE_BASE_ID}/retrieve"
headers = {
"accept": "application/json",
"Authorization": f"Bearer {JWT}",
"Content-Type": "application/json",
}
body = {"query": "What is the parental leave policy?", "retrieval_mode": "hybrid", "top_k": 5}
response = requests.post(url, json=body, headers=headers)
print(response.json())
Manage knowledge bases
Use the Management API to create and configure repositories, knowledge bases, sources, schema mappings, and ingestion jobs. Use the Management API base URL for your environment, for example https://management-api.prod.kh.boomi.com.
Explore the API references
For a complete list of endpoints and request and response details, refer to the following references: