Uploading files

This guide describes how to upload a file using the API

Introduction

Torii supports various features which involve uploading files, such as: importing contracts, uploading expense files, and syncing custom integrations' data.

Files are uploaded and stored securely on AWS's S3, encrypted both in transit and at rest.

How-To Guide

Small files (up to 3MB)

To upload a small file using the public API, you can make the following request:

curl --header "Authorization: Bearer API_KEY" \
     --form file=@"PATH/TO/YOUR/FILE" \
     --form type={FILE_TYPE} \
     https://api.toriihq.com/v1.0/files/upload

Read the full Upload File API reference to learn more.

Large files (3MB or larger)

  1. To upload a file using the public API, you need to follow these 3 steps:
    Ask for an upload URL. This is a secure, temporary S3 URL:
    curl -H "Authorization: Bearer API_KEY" \
         https://api.toriihq.com/v1.0/files/url?name={FILE_NAME}&type={CONTENT_TYPE}
    
    It returns a URL (used in step #2) and the file's path (used in step #3)
    Read the full Get parameters for uploading files API reference to learn more.
  2. Use the URL returned in step #1 to upload the file directly to S3:
    curl -H "Content-Type: {CONTENT_TYPE}" \
         -X PUT {S3_URL}
         --data-binary @'PATH/TO/YOUR/FILE'
    
  3. Inform Torii that the file has been uploaded successfully:
    curl -H "Authorization: Bearer API_KEY"
         -H "Content-Type: application/json"
         -d '{"path":"{FILE_PATH}","type":"{FILE_TYPE}"}'
         https://api.toriihq.com/v1.0/files
    
    It returns a unique file identifier that can be used to get additional information about this upload.