Topics on this page

View, upload, and delete an attachment to an existing quote

In BriteCore, the word attachment refers to any file or document that you upload to a policy, claim, or contact. In the BriteCore UI, each module (Policies, Quote, etc.) contains an Attachments screen that allows you to upload and access new/existing documents. In addition to creating and binding a quote, BriteQuote provides an Attachments API that supports:

  • Creating an attachment object.
  • Uploading a file to the attachment object.
  • Getting/Listing attachments.
  • Deleting attachments.

Creating an attachment object is a two-step process:

  1. Create the attachment object in BriteQuote’s backend.
  2. Upload the actual file to the pre-signed S3 URL returned by the create attachment call.

Note: Blocks of code are hidden by default to make the page more navigable. Select View code and Hide code to view or hide these sections as needed.

Step 1: Get a security token

You will need to request an ID and Secret to use OAuth 2.0.

For more information, refer to How do I get started?

Step 2: Retrieve list of quotes

Use the listQuote endpoint (/quote) to retrieve the list of quotes you can access. You will need the quote number to continue to step 3.

Sample request

View code
curl --request GET \
--url '/quote/' \
--header 'authorization: '

Sample response

View code
"data": [
{
"type": "quotes",
"id": "bac0189e-9d66-434c-861c-91eb105ca050",
"attributes": {
"quote_number": "Q-personalAutoCW-2020-313",
"status": "Approved",
"policy_state": {
"policy": {
"external_id": "fb85887a-1200-4c8d-8596-af935f267ee5",
"number": "10-2020-293",
"redirect_uri": "/policies/policy/fb85887a-1200-4c8d-8596-af935f267ee5",
"inception_date": "2020-08-05"
},
"term": {
"effective_date": "2020-09-01",
"expiration_date": "2021-08-05"
},
"revision": {
"revision_date": "2020-09-01",
"description": "New Policy"
}
},
"product_name": "personalAutoCW",
"product_version": "98f2af68-c252-47d6-bbc1-7c925e1443ef",
"product_label": "Personal Auto - Countrywide",
"is_bound": true,
"submitted_for_review_date": null,
"date_added": "2020-08-05T13:52:23.454334Z"
},
"relationships": {
"root_risk_quote": {
"data": {
"type": "risk-quotes",
"id": "ee68dcea-8db5-484c-a5f6-651edbf18c9d"
}
},
"agency": {
"data": {
"type": "quote-contacts",
"id": "b2a030ae-7ffb-4ddd-a3a0-e038338fdd24"
}
},
"agents": {
"data": [
{
"type": "quote-contacts",
"id": "42c23c67-2a11-43e3-90aa-062780f19e91"
}
]
},
"owner": {
"data": {
"type": "contacts",
"id": "c9bf582d-cc31-415c-888a-8984b6d5afc7"
}
},
"named_insured": {
"data": {
"type": "quote-contacts",
"id": "ba77ecaf-5fa3-41b8-9d49-b72fb0b10202"
}
}
}
}

Step 3: Create an attachment (upload documents)

Use createAttachment (/quote/{quote_number}/attachments/) to link an attachment resource to the quote. You can add an attachment at any time during the quoting process. You need the Quote_number from step 2. You will need the response payload from this step to upload the attachment in step 4.

The request payload includes a JSON object with the following details:

View code
{
"name": "report.pdf",
"content_type":
"application/pdf",
 
"size": 235983
}

Sample request

View code
curl --request POST \
--url /quote/Q-personalAutoCW-2020-311/attachments/ \
--header 'authorization: ' \
--data '{
"name": "sample 2.pdf",
"content_type": "application/pdf",
"size": 23598
}

Sample response

View code
{
"id": "ae20bdae-df2a-48e1-950a-2bddd6d4713b",
"name": "sample 2.pdf",
"quote": "4f82c9e8-8019-48ae-aa2e-79c2f1272866",
"date_added": "2020-08-05T19:03:05.278096Z",
"content_type": "application/pdf",
"size": 23598,
"file_location": {
"url": "https://sc-435336252314-pp-nzcdsc3tcrjoq-attachmentbucket-14kcwyy1ytiuk.s3.amazonaws.com/",
"fields": {
"key": "4f82c9e8-8019-48ae-aa2e-79c2f1272866/ae20bdae-df2a-48e1-950a-2bddd6d4713b_sample 2.pdf",
"AWSAccessKeyId": "ASIAWKXAQBONB5OAJHGG",
"x-amz-security-token": "",
"policy": "",
"signature": ""
}
}
}

Step 4: Upload the file directly to S3

Upload the file directly to S3 using the data from step 3. To do that, issue a multipart POST request to the response.file_location.url resource, passing the file itself and all the fields in response.file_location.fields in the form.

In this example, we will make a multipart POST request to the URL: https://sc-435336252314-pp-nzcdsc3tcrjoq-attachmentbucket-14kcwyy1ytiuk.s3.amazonaws.com/

With the fields key, AWSAccessKeyId, x-amz-security-token, policy, signature, and file populated as shown in Figure 1.

Figure 1: Multipart POST request.

Note: The name of the file above will be overwritten by the one you added when you created the resource if they differ.

Sample request

View code
curl --request POST \
--url https://sc-435336252314-pp-nzcdsc3tcrjoq-attachmentbucket-14kcwyy1ytiuk.s3.amazonaws.com/ \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--form Policy= \
--form 'x-amz-security-token=' \
--form AWSAccessKeyId= \
--form 'key=4f82c9e8-8019-48ae-aa2e-79c2f1272866/ae20bdae-df2a-48e1-950a-2bddd6d4713b_sample 2.pdf' \
--form Signature= \
--form file=

Sample response

You will receive a return status 204 for successful responses.

Step 5: List attachments

Use listAttachments (/quote/{quote_number}/attachments/) to retrieve a list of all attachments connected to the quote and confirm your upload.

Note: You can add revision_id to the JSON body as a parameter to filter accordingly.

Sample payload

View code

{

"revision_id": "ef7909a8-a088-4745bbbf-614bdd9f9031"

}

Sample request

View code
curl --request GET \
 --url https://api.policies-sandbox.britecore.com/quote/Q-personalAutoCW-2020-311/attachments/ \
--header 'authorization: '
--data '{"id":"ef7909a8-a088-4745bbbf-614bdd9f9031","type":"policies","orderBy":"dateAdded","ascending":false}

Sample response

View code

{
"folders":[
],
"activePage":1,
"folderName":null,
"records":[
{
"isdir":true,
"actualPrintDate":null,
"printState":"Do Not Print or Email",
"folderId":null,
"mimeType":null,
"uploadingToS3":false,
"emailOnly":false,
"url":"/gateway?file=core.uploads&method=getAttachment&id=4490a610-78de-43b7-a957-f2767f615f27",
"title":"Installment Billing Statement",
"folderIsPrivate":null,
"printDateFmt":null,
"id":"4490a610-78de-43b7-a957-f2767f615f27",
"edeliveryState":null,
"readOnly":true,
"folderName":null,
"private":false,
"dateAddedFmt":"05/03/2021 01:50 PM",
"itemCount":1,
"certifiedMail":null,
"size":"4.0 KB"
},
{
"isdir":true,
"actualPrintDate":null,
"printState":"Do Not Print or Email",
"folderId":null,
"mimeType":null,
"uploadingToS3":false,
"emailOnly":false,
"url":"/gateway?file=core.uploads&method=getAttachment&id=929ec061-9307-4b65-9dc9-2397387e52eb",
"title":"Initial Billing Statement",
"folderIsPrivate":null,
"printDateFmt":null,
"id":"929ec061-9307-4b65-9dc9-2397387e52eb",
"edeliveryState":null,
"readOnly":true,
"folderName":null,
"private":false,
"dateAddedFmt":"05/03/2021 01:50 PM",
"itemCount":1,
"certifiedMail":null,
"size":"4.0 KB"
},
{
"isdir":true,
"actualPrintDate":null,
"printState":"Do Not Print or Email",
"folderId":null,
"mimeType":null,
"uploadingToS3":false,
"emailOnly":false,
"url":"/gateway?file=core.uploads&method=getAttachment&id=ae12edda-8aad-4fa2-9539-c1e193791214",
"title":"Private",
"folderIsPrivate":null,
"printDateFmt":null,
"id":"ae12edda-8aad-4fa2-9539-c1e193791214",
"edeliveryState":null,
"readOnly":true,
"folderName":null,
"private":true,
"dateAddedFmt":"05/03/2021 01:50 PM",
"itemCount":0,
"certifiedMail":null,
"size":"4.0 KB"
}
],
"maxPages":1,
"canMakePrivate":true
}

Step 6: Delete an attachment

Use the deleteAttachment endpoint (/quote/{quote_number}/attachments/{attachment_id}/) to delete a single attachment connected to the quote. The quote_number and attachment_id are required.

Note: Currently, you can delete only one file at a time.

Sample request

View code
curl --request DELETE \
--url /quote/Q-personalAutoCW-2020-311/attachments/ae20bdae-df2a-48e1-950a-2bddd6d4713b \
--header 'authorization: '

Sample response

You will receive a status 204 if the delete succeeds and a status 404 if the attachment doesn’t exist.

You have successfully viewed, uploaded, and deleted an attachment with an existing quote.