AI Chatbot Hub
HomepageAPI docsDiscordLog inSign up
API docs
API docs
  • API usage guides
    • Getting an API key
    • Create a chatbot
    • Chat with chatbot
    • Uploading data sources
  • Chatbots
    • Chatbot properties
    • Create chatbot
    • Update chatbot
    • Fetch a chatbot
    • Fetch all chatbots
    • Delete chatbot
  • Agents
    • Agent properties
    • Create agent
    • Update agent
    • Fetch all agents
    • Delete agent
  • Chatbot sessions
    • Session properties
    • Create session
    • Fetch a session
    • Fetch all sessions
    • Delete session
  • Session messages
    • Message properties
    • Create message
    • Fetch all messages
    • Delete message
    • Delete multiple messages
  • Data sources
    • Source properties
    • Upload a file
    • Create QA source
    • Create URL source
    • Update source
    • Fetch list of sources
    • Retrain sources
    • Delete source
    • Delete multiple sources
  • Data source tags
    • Create source tag
    • Fetch all source tags
    • Update source tag
    • Delete source tag
Powered by GitBook
On this page
  • Endpoint
  • Authorization
  • Path
  • ​Body
  • Request example
  • ​Response
  • Response example
  1. Data sources

Upload a file

Create a File source for a chatbot specified by chatbot uuid

PreviousSource propertiesNextCreate QA source

Last updated 6 months ago

Endpoint

POST / api / v1 / chatbot / {uuid} / data-source / upload

Authorization

Authorization string Bearer <your_token>

Path

uuid string required

Body

file_path string required

reference_source_link string

Request example

curl -X POST -F "file=@{file_path}" 'meta_json="{\"reference_source_link\": \"{reference_source_link}\"}
"' https://app.aichatbothub.com/api/v1/chatbot/{uuid}/data-source/upload \
--header 'Authorization: Bearer <token>' 
import requests
import os

file_path = '{file_path}'

api_url = 'https://app.aichatbothub.com/api/v1/chatbot/{uuid}/data-source/upload'

headers = {
    "Authorization": "Bearer <token>"
}

file_name = os.path.basename(file_path)

files = {'file': (file_name, open(file_path, 'rb'))}

payload={'reference_source_link': '{reference_source_link}'}

response = requests.post(api_url, files=files, data=payload, headers=headers)

if response.status_code == 200:
    print('File upload successful:', response.text)
else:
    print('File upload failed:', response.status_code, response.text)
const fs = require("fs");
const FormData = require("form-data");
const axios = require("axios");

const filePath = "{file_path}";
const apiUrl =
  "https://app.aichatbothub.com/api/v1/chatbot/{uuid}/data-source/upload";

const fileName = filePath.split("/").pop();

const fileStream = fs.createReadStream(filePath);

const formData = new FormData();
formData.append("file", fileStream, fileName);
formdata.append("reference_source_link", "{reference_source_link}");

axios
  .post(apiUrl, formData, {
    headers: {
      "Content-Type": "multipart/form-data",
      Authorization: "Bearer {api_key}",
    },
  })
  .then((response) => {
    console.log("File upload successful:", response.data);
  })
  .catch((error) => {
    console.error("File upload failed:", error);
  });

Response

created_at string

file_name string

file_size number

meta_json string

modified_at string

status string

title string

type string

tokens number

Response example

{
  "created_at": "string",
  "file_name": "string",
  "file_size": 0,
  "meta_json": "string",
  "modified_at": "string",
  "status": "string",
  "title": "string",
  "tokens": 0,
  "type": "string",
  "uuid": "string"
}

uuid string

​
​