Search Knowledge Chunks
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. 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. 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.
A unique Knowledge Base ID using Twilio Type ID (TTID) format
know_knowledgebase_00000000000000000000000000Pattern: ^know_knowledgebase_[0-7][0-9a-z]{25}$application/jsonThe list of knowledge IDs to search.
100OK
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function createKnowledgeSearch() {14const search = await client.knowledge.v215.search("know_knowledgebase_00000000000000000000000000")16.create({17query: "How do I reset my password?",18top: 5,19knowledgeIds: ["know_knowledge_00000000000000000000000000"],20});2122console.log(search.chunks);23}2425createKnowledgeSearch();
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}