Update a Chatbot

This page helps you update a Chatbot.

Update API Guide

The Chatbot Data Update API allows you to update the data for a chatbot by providing the chatbot ID, new name, and source text for text content. This API can be used to replace the existing data of a chatbot with new information.

Endpoint

POST https://www.chatbase.co/api/v1/update-chatbot-data

Request Headers

The API request must include the following header:

  • Authorization: Bearer <Your-Secret-Key> - The secret key for authenticating the API request.

Request Payload

The request payload should be sent as a JSON object in the body of the API request. The payload can include the following parameters:

  • chatbotId (required): A unique identifier for the chatbot. It helps to identify the specific chatbot whose data needs to be updated.

  • chatbotName (required): The new name for the chatbot. This parameter allows you to update the name of the chatbot.

  • sourceText (required): The new source text to update the chatbot. This parameter should contain the new text content that replaces the existing data. The source text should be less than the character limit allowed by your plan.

Example Request

const res = await fetch('https://www.chatbase.co/api/v1/update-chatbot-data', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <Your-Secret-Key>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    chatbotId: 'example-123',
    chatbotName: 'new name',
    sourceText: 'Source text that is less than your plan character limit...'
  })
});

const data = await res.json();

console.log(data); // {chatbotId: 'exampleId-123'}
import requests
import json

url = 'https://www.chatbase.co/api/v1/update-chatbot-data'
headers = {
    'Authorization': 'Bearer <Your-Secret-Key>',
    'Content-Type': 'application/json'
}
data = {
    'chatbotId': 'example-123',
    'chatbotName': 'new name',
    'sourceText': 'Source text that is less than your plan character limit...'
}

response = requests.post(url, headers=headers, data=json.dumps(data))
data = response.json()

print(data)  # {'chatbotId': 'exampleId-123'}
curl https://www.chatbase.co/api/v1/update-chatbot-data \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <Your-API-Key>' \
  -d '{
    "chatbotId": "example-123",
    "chatbotName": "new name",
    "urlsToScrape": [
      "https://www.example.com",
      "https://www.example.com/blog"
    ]
  }'
POST /api/v1/update-chatbot-data HTTP/1.1
Host: www.chatbase.co
Authorization: Bearer <Your-Secret-Key>
Content-Type: application/json

{
  "chatbotId": "example-123",
  "chatbotName": "new name",
  "sourceText": "Source text that is less than your plan character limit..."
}

Response

The API response will be a JSON object with the following structure:

{
  "chatbotId": "exampleId-123"
}

The chatbotId field in the response contains the unique identifier assigned to the created chatbot.

Error Handling

If there are any errors during the API request, appropriate HTTP status codes will be returned along with error messages in the response body. Make sure to handle these errors gracefully in your application.

That's it! You should now be able to update a chatbot using the Chatbot Update API.


What’s Next