POST
/
datasources

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://app.fiscalohq.com/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}`,
  },
});

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

const apiUrl = 'https:/app.fiscalohq.com/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}`,
  },
});

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

const apiUrl = 'https://app.fiscalohq.com';
const apiKey = 'XXX';
const datastoreId = 'XXX';

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

      // Or Auto Discovery
      source_url: 'https://docs.fiscalohq.com',
    },
  }),
  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
file
required
type
enum<string>
required
Available options:
file
datastoreId
string
required
fileName
string
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