cURL
curl --request POST \ --url https://gptbots.chat/datasources \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form 'fileName=<string>' \ --form type=file \ --form 'datastoreId=<string>' \ --form 'custom_id=<string>' \ --form file=@example-file
{ "id": "<string>", "type": "<string>", "name": "<string>", "status": "unsynched", "groupId": "<string>", "updatedAt": "2023-12-25", "createdAt": "2023-12-25", "lastSynch": "2023-12-25", "config": {} }
const apiUrl = 'https://gptbots.chat/api'; 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}`, }, });
const apiUrl = 'https:/gptbots.chat/api'; 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', }, }), headers: { ContentType: 'application/json', Authorization: `Bearer ${apiKey}`, }, });
const apiUrl = 'https://gptbots.chat'; const apiKey = 'XXX'; const datastoreId = 'XXX'; const res = await fetch(`${apiUrl}/datasources`, { method: 'POST', body: JSON.stringify({ datastoreId, type: 'web_site', name: 'Gptbots Docs', config: { // Sitemap sitemap: 'https://docs.gptbots.chat/sitemap.xml', // Or Auto Discovery source_url: 'https://docs.gptbots.chat', }, }), headers: { ContentType: 'application/json', Authorization: `Bearer ${apiKey}`, }, });
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Bearer <token>
<token>
Success
The response is of type object.
object