Can I upload files over the API?
Yes! We support adding file attachments over the API.
The basic high level overview of how to use this API involves 3 steps an integrator must take:
Create an attachment token and pre-signed upload data
Upload the file to AWS S3 utilizing the provided pre-signed upload data provided in step 1.
Create or update a case/alert with the attachment token provided in step 1.
All requests to the Hummingbird API should include an Authorization header with your access token. For additional details on authorization and detailed specification for the API, refer to our API documentation.
1. Create an attachment token POST /attachments
POST /attachments
The first step is to fetch an attachment token and details on where to upload your attachment file. The following is an example curl request. The only data required is the filename
of the file you plan to upload and the mime_type
of the file.
We do have restrictions on the types of files that are allowed to be uploaded. At this time, we allow:
image/*
,audio/*
, andtext/*
file typesapplication/pdf
andapplication/zip
filesCSVs with a mime type of
text/csv
Excel (xlsx only) with a mime type of
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Files can be up to 100mb in size
The response will include two attributes: token
and upload
. Here is an example response:
The upload data describes where/how to upload your attachment file to S3 while the token is to be used later when creating/update a case.
If you plan to include multiple attachment files on a case you will need to send a request to POST /attachments
for each file you plan to attach. Keep each token and submit them all as part of your case data in step 3 below.
2. Uploading your attachment file to AWS S3
To upload a file to S3 you must send a multipart/form-data request using the data provided in the previous step.
From the response you received above in step 1 we have the portion that represents your upload:
We use this data to build our multipart/form-data request. Note the attributes nested under fields are the form fields to be included in the request. All fields are required to be submitted along with a the file.
Please note that the content-type of the request should be multipart/form-data. This is different than the ‘Content-Type’ form field data provided.
Upon a successful upload we are now good to create/update a case.
3. Create/Update a case with an attachment
Case
Now it is time to put the attachment token
we received in step 1 to use. Using or cases API we can now submit our attachment(s) to be included on our case.
Here is an abbreviated example payload to POST /cases
with an attachment:
Up to 10 attachments can be uploaded to a case in this manner. The same attachments format can be used when updating a case.
Alert
You can use a similar format to upload an alert, include attachment token
in the data section of the alert payload
Here is an example payload that can be submitted to POST /alerts
Up to 10 attachments can be included with each call to the Alert API.
Fetching Attachments From a Case
You can also pull attachment files from a case to download to your own system of record. To fetch attachment data along with a pre-signed url enabling you to download the file, make a request to GET /cases/{case_token}/attachments
. The same attachment data is included when fetching an a case as well (GET /cases/{case_token}
).
An example response is as follows:
Frequently Asked Questions
How can I test these APIs?
We recommend testing in your Sandbox environment. Remember that Sandbox is only designed for use with fake data, and no PII should be sent.
What is the lifespan of the pre-signed URLs?
10 minutes
Can I upload multiple files using the same attachment S3 url and upload data?
You will need to request a new attachment token/upload data (step 1 above) for each file you wish to upload and attach to a case. AWS S3 will allow you to upload multiple files using the same upload data (assuming it hasn’t expired). If you upload more than one file using the same upload data, older uploaded files will be overwritten and only the last file you uploaded will be added to the case.
Can I attach the same file to multiple cases?
An attachment token can only be used once to associate a file with an attachment on a case. If you want to upload the same file to multiple cases you will need to request a new attachment token and upload the file to S3 for each case.
Why do I need to create three separate requests in order to attach a file through API?
At this time, we want to avoid having files transiting our backend to be uploaded. Very large files could potentially cause performance issues. With that, we're currently utilizing AWS S3's file upload capabilities which handles upload, retry, and chunking efficiently.
Last updated