Skip to contentSkip to navigationSkip to topbar

Search Knowledge Chunks


(information)

Legal information

Enterprise Knowledge, including the APIs, may use artificial intelligence or machine learning technologies and is subject to the terms of the Predictive and Generative AI/ML Features Addendum(link takes you to an external page). For more details on AI usage and data, see the AI Nutrition Facts.

Enterprise Knowledge is not a HIPAA Eligible Service or PCI compliant and should not be enabled in workflows that are subject to HIPAA or PCI.

Conversations products are only available in the new Twilio Console(link takes you to an external page). If your account hasn't been migrated, you'll be redirected to the legacy Console where these products won't appear.

POST/v2/KnowledgeBases/{kbId}/Search

Base url: https://knowledge.twilio.com (base url)

Perform semantic search across knowledge sources within a knowledge base to find the most relevant content chunks based on a natural language query. Returns ranked chunks with similarity scores, allowing you to retrieve contextually relevant information for AI applications, chatbots, or information retrieval systems. You can filter results by specific knowledge sources.


Request

create-knowledge-search-request page anchor

Authentication

authentication page anchor
Property nameTypeRequiredPIIDescription
kbIdstring
required
Not PII

A unique Knowledge Base ID using Twilio Type ID (TTID) format

Example: know_knowledgebase_00000000000000000000000000Pattern: ^know_knowledgebase_[0-7][0-9a-z]{25}$
Encoding type:application/json
SchemaExample
Property nameTypeRequiredPIIDescriptionChild properties
querystring
required

The query to search the knowledge source.

Max length: 2048

topinteger
required

The top K results to return.

Minimum: 1Maximum: 20

knowledgeIdsarray[string]

Optional

The list of knowledge IDs to search.

Max items: 100

200400401403404429500503

OK

SchemaExample
Property nameTypeRequiredPIIDescriptionChild properties
chunksarray[object]

Optional

Max items: 100
Search Knowledge ChunksLink to code sample: Search Knowledge Chunks
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID at twilio.com/console
5
// Provision API Keys at twilio.com/console/runtime/api-keys
6
// and set the environment variables. See http://twil.io/secure
7
// For local testing, you can use your Account SID and Auth token
8
const accountSid = process.env.TWILIO_ACCOUNT_SID;
9
const apiKey = process.env.TWILIO_API_KEY;
10
const apiSecret = process.env.TWILIO_API_SECRET;
11
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });
12
13
async function createKnowledgeSearch() {
14
const search = await client.knowledge.v2
15
.search("know_knowledgebase_00000000000000000000000000")
16
.create({
17
query: "How do I reset my password?",
18
top: 5,
19
knowledgeIds: ["know_knowledge_00000000000000000000000000"],
20
});
21
22
console.log(search.chunks);
23
}
24
25
createKnowledgeSearch();

Response

Note about this response
1
{
2
"chunks": [
3
{
4
"content": "To reset your password, go to the login page and click 'Forgot Password'. Enter your email address and follow the instructions in the reset email.",
5
"knowledgeId": "know_knowledge_00000000000000000000000001",
6
"createdAt": "2026-01-15T10:30:00Z",
7
"chunkIndex": 3,
8
"documentTitle": "Account Help — Example Docs",
9
"documentUrl": "https://docs.example.com/account/password-reset"
10
},
11
{
12
"content": "If you're having trouble with password reset, contact support at help@example.com or call 1-800-HELP.",
13
"knowledgeId": "know_knowledge_00000000000000000000000002",
14
"createdAt": "2026-01-15T10:30:00Z",
15
"chunkIndex": 7,
16
"documentTitle": "Contact Support — Example Docs",
17
"documentUrl": "https://docs.example.com/support/contact"
18
}
19
]
20
}