POST
/
datasources
curl --request POST \
  --url https://api.chatvolt.ai/datasources \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'file=<string>' \
  --form 'fileName=<string>' \
  --form type=file \
  --form 'datastoreId=<string>' \
  --form 'custom_id=<string>'
{
  "id": "<string>",
  "type": "<string>",
  "name": "<string>",
  "status": "unsynched",
  "groupId": "<string>",
  "updatedAt": "2023-12-25",
  "createdAt": "2023-12-25",
  "lastSynch": "2023-12-25",
  "config": {}
}

File upload supported mime types

  • text/csv’
  • text/plain’
  • text/markdown’
  • application/pdf’
  • application/json’
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

Example JS Code to create a Datasource of type ‘file’

const apiUrl = 'https://api.chatvolt.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const fileName = 'test.pdf';
const buffer = fs.readFileSync(fileName);

const formData = new FormData();

formData.append(
  'file',
  new Blob([buffer], {
    type: 'application/pdf',
  }),
  fileName
);

formData.append('type', 'file');
formData.append('datastoreId', datastoreId);
formData.append('fileName', fileName);

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: formData,
  headers: {
    Authorization: `Bearer ${apiKey}`,
  },
});

Example JS Code to create a Datasource of type ‘web_page’

const apiUrl = 'https://api.chatvolt.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_page',
    name: 'Nuclear Fusion - Wikipedia',
    config: {
      source_url: 'https://en.wikipedia.org/wiki/Nuclear_fusion',
      tags: [nuclear, fusion, generation],
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});

Example JS Code to create a Datasource of type ‘web_site’ with a sitemap

const apiUrl = 'https://api.chatvolt.ai';
const apiKey = 'XXX';
const datastoreId = 'XXX';

const res = await fetch(`${apiUrl}/datasources`, {
  method: 'POST',
  body: JSON.stringify({
    datastoreId,
    type: 'web_site',
    name: 'Chatvolt Docs',
    config: {
      // Sitemap
      sitemap: 'https://docs.chatvolt.ai/sitemap.xml',

      // Or Auto Discovery
      source_url: 'https://docs.chatvolt.ai',

      tags: [chatvolt, genai, chatbots],
    },
  }),
  headers: {
    ContentType: 'application/json',
    Authorization: `Bearer ${apiKey}`,
  },
});

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

file
string
required
fileName
string
type
enum<string>
required
Available options:
file
datastoreId
string
required
custom_id
string

Useful for multi-tenant setups

Response

200 - application/json
id
string
type
string
name
string
status
enum<string>
Available options:
unsynched,
pending,
running,
synched,
error,
usage_limit_reached
groupId
string
updatedAt
string
createdAt
string
lastSynch
string
config
object