POST
/
api
/
external
/
datastores
/
file-upload
/
{datastoreId}

Path

datastoreId
string
required

The id of the datastore where you want to upload a file.

content-type
string
default: "multipart/form-data"required

Content Type must be set to multipart/form-data

Body

file
file
required

File to upload

fileName
string

File Name

custom_id
string

Custom ID: If you want to set a custom ID for the file, you can do it here.

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

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('fileName', fileName);

// Request upload link
const res = await fetch(
  `${apiUrl}/api/external/datastores/file-upload/${datastoreId}`,
  {
    method: 'POST',
    body: formData,
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  }
);