https://retellai.com/?utm_source=discord&utm_medium=seo logo
Is there a PATCH update knowledge base endpoint th...
# ❓・ai-evy-support
g
@AI Evy Is there a PATCH update knowledge base endpoint that can be used to replace files in an existing knowledge base? I’m getting a .csv file regularly for an agent that I’m building and there’s not a great way to do this with what’s publicly available on the api documentation site
a
Thanks for tagging me @gharpe2. I'll look through relevant sources and get back to you shortly.
### Answer Based on the available documentation, there isn't a dedicated PATCH endpoint for updating or replacing files in an existing knowledge base. However, you can achieve file replacement through a two-step process: 1. Delete the existing source using the DELETE endpoint [(1) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const knowledgeBaseResponse = await client.knowledgeBase.deleteSource(
  'kb_1234567890',
  'source_1234567890',
) ;
console.log(knowledgeBaseResponse.knowledge_base_id) ;
2. Add the new source using the
addSources
method [(2) ]() :
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const knowledgeBaseResponse = await client.knowledgeBase.addSources({
  knowledge_base_files: [
    fs.createReadStream("../sample.txt") ,
  ],
}) ;
console.log(knowledgeBaseResponse.knowledge_base_id) ;
To identify which source to delete, you can use the List Knowledge Bases endpoint to retrieve
knowledge_base_sources
which includes
source_id
for each source [(3) ]() . For your recurring .csv updates, you'd need to automate this delete-then-add workflow.
​ To learn more, see the sources I considered: [[1] Delete Knowledge Base Source](https://docs.retellai.com/api-references/delete-knowledge-base-source) [[2] Major Issue with KB](https://community.retellai.com/t/major-issue-with-kb/228) [[3] List Knowledge Bases](https://docs.retellai.com/api-references/list-knowledge-bases) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
@AI Evy how would we update with kb source the agent is reverencing. We would need to patch the agent with the new ID? is that doab;e
a
Thanks for the follow-up, @Dan. I'll get back to you soon.
### Answer Yes, you can update the knowledge base your agent references. The approach depends on your agent type: For Conversation Flow agents, you can update the
knowledge_base_ids
field using the Update Conversation Flow endpoint: [(1) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const conversationFlowResponse = await client.conversationFlow.update('conversation_flow_id') ;
console.log(conversationFlowResponse.conversation_flow_id) ;
The
knowledge_base_ids
parameter accepts an array of knowledge base IDs (e.g.,
["kb_001", "kb_002"]
) . For Voice Agents and Chat Agents, the knowledge base is typically configured within the Response Engine (the attached Retell LLM) , not directly on the agent itself. [(2) ]() [(3) ]() So to answer your question: if you're using a Conversation Flow, you can directly patch it with updated
knowledge_base_ids
. If you're using a Retell LLM as your response engine, you'd update the knowledge base configuration on the LLM itself rather than the agent.
​ To learn more, see the sources I considered: [[1] Update Conversation Flow](https://docs.retellai.com/api-references/update-conversation-flow) [[2] Update Voice Agent](https://docs.retellai.com/api-references/update-agent) [[3] Update Chat Agent](https://docs.retellai.com/api-references/update-chat-agent) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.