Getting Files
Get additional data and the contents of a file.
Herald is continuously expanding our file offering. If you would like a file that is not listed in our list of supported file types, please reach out to our team at hello@heraldapi.com.
Herald returns files in the files array. The files array can contain a single file or multiple files, while a null value means there are no relevant files available. The files array is currently returned in quotes and policies. Here’s an example from the quote response:
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"product_id": "prd_mc4r_herald_general_liability",
"status": "active",
"files": [
{
"id": "d7c4579a-5450-4e79-bcfc-e918b3c8a564",
"type": "quote_summary",
"text": "Quote Summary",
"status": "available"
},
{
"id": "138fcedd-c394-46e6-b025-3f62a191223d",
"type": "application",
"text": "Application",
"status": "processing"
}
],
....
}In the response above, there are two types of files for this quote: a quote_summary and an application. The status of a file can be available, processing, unresponsive or deleted.Using the file’s id, you can:
- Get a temporary link to access the contents of the file, using
/files/{file_id}/get_temporary_link. This provides you with a temporary link to access the content of a file that expires in 15 minutes. - Get more details on the file, using
/files/{file_id}. This provides you with additional information like the filessizeandfile_name. Read the full list of file metadata.
| Status | Description |
|---|---|
available | This file is available in Herald. |
processing | Herald is waiting for an institution to prepare this file. |
unresponsive | Herald was expecting a file, but the institution did not provide it. |
deleted | This file has been deleted from Herald*. |
*Once a file is deleted, you can no longer create a temporary link to access the contents of a file, but you can still access the metadata. For quotes, all files are deleted 24 hours after the quote expires.
Getting a Temporary Link
You can only get temporary links for files with an
availablestatus
You can get a temporary link to a file using /files/{file_id}/get_temporary_link. Making a POST request to this endpoint will generate a temporary link to the file that expires in 15 minutes. With each request, you will receive a new temporary link that expires 15 minutes after it is generated.
In the example above, we have a file_id for a Quote Summary. Making a POST request with the file id will return the following:
{
"temporary_link": {
"link": "https://files-sandbox.heraldapi.com/quote_summary/herald_quote_summary_05aefd0b-0dea-4c35-8248-7084cc7b247f.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=DO00KTMX4NHPECHT8VNW%2F20221219%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221219T080446Z&X-Amz-Expires=900&X-Amz-Signature=1d572ab767fc963f3b16573fa68ece5ff9431c46f38598b444ecaf8cd00ce5a9&X-Amz-SignedHeaders=host&x-id=GetObject"
}
}The temporary link can be used to retrieve a file without authentication. Since these links are temporary, they are best created at the intent to access a file. On your front-end, you may choose to allow users to download the file directly to their computer or open the file’s link in a browser. To avoid stale links in these scenarios, it’s best to get the temporary link when those buttons are clicked.
Herald recommends you do not display the URL of a temporary link on your front-end
All files are hosted by Herald, and are periodically deleted. Once a file is deleted, you can no longer get a temporary link to access the contents of the file. Files are deleted after a certain amount of time based on the files type. For example, a Quote Summary is deleted 24 hours after the quote expires.
You can download and store files in your own file system. If you would like to store files on your own system, you can use file_name when saving the file.
Getting File Details
When a file is represented within the files array of another resource, only a subset of the file details are present. You can get the full details of a file using GET/files/{file_id}, regardless of the files status.
The response contains all of the metadata for the file, which is documented here.
{
"file": {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"type": "quote_summary",
"format": "pdf",
"file_name": "herald_quote_summary_05aefd0b-0dea-4c35-8248-7084cc7b247f.pdf",
"text": "Quote Summary",
"created_at": "2022-12-19",
"size": 124212,
"status": "available",
"associations": [
{
"object_type": "quote",
"object_id": "5193ce22-7f33-4c13-9077-7587e0e2dc3a"
}
}
}Using Files
When you are setting up files on your front end, we recommend that you create a button to retrieve the file. Once you click the button, you make a POST request to /files/{file_id}/get_temporary_link which will then direct the user to link which contains the file. This link can either download the file or open the file in a browser window.