Skip to Content
API ReferenceDocuments API

Documents API

The Documents API provides endpoints for managing documents attached to customs declarations. You can list, view, download, upload, and update document metadata.

Required Scope: declarations:read (list, view, download), declarations:write (upload, update)

List Documents

Retrieve all documents for a declaration.

curl -X GET "https://app.borderbolt.com/api/v1/declarations/12345/documents" \ -H "Authorization: Bearer your-access-token" \ -H "Accept: application/json"

Response

{ "data": [ { "id": 101, "original_filename": "invoice-2026-001.pdf", "mime_type": "application/pdf", "file_size": 245760, "file_size_human": "240 KB", "document_type": "invoice", "description": "Commercial invoice for shipment", "created_at": "2026-03-25T10:30:00+00:00", "updated_at": "2026-03-25T10:30:00+00:00" }, { "id": 102, "original_filename": "packing-list.pdf", "mime_type": "application/pdf", "file_size": 102400, "file_size_human": "100 KB", "document_type": "packing_list", "description": null, "created_at": "2026-03-25T10:35:00+00:00", "updated_at": "2026-03-25T10:35:00+00:00" } ], "meta": { "total": 2, "document_types": [ "invoice", "packing_list", "bill_of_lading", "airway_bill", "cmr", "certificate_of_origin", "eur1", "atr", "health_certificate", "phytosanitary", "import_permit", "export_permit", "customs_valuation", "insurance", "contract", "correspondence", "utb", "emergency_procedure", "sad", "other" ] } }

Get Single Document

Retrieve metadata for a specific document.

curl -X GET "https://app.borderbolt.com/api/v1/declarations/12345/documents/101" \ -H "Authorization: Bearer your-access-token" \ -H "Accept: application/json"

Response

{ "data": { "id": 101, "original_filename": "invoice-2026-001.pdf", "mime_type": "application/pdf", "file_size": 245760, "file_size_human": "240 KB", "document_type": "invoice", "description": "Commercial invoice for shipment", "created_at": "2026-03-25T10:30:00+00:00", "updated_at": "2026-03-25T10:30:00+00:00" } }

Download Document

Download the actual file content of a document.

curl -X GET "https://app.borderbolt.com/api/v1/declarations/12345/documents/101/download" \ -H "Authorization: Bearer your-access-token" \ --output invoice-2026-001.pdf

Response

Returns the file as a streamed download with the appropriate Content-Type and Content-Length headers.

HeaderDescription
Content-TypeMIME type of the file (e.g., application/pdf)
Content-LengthFile size in bytes
Content-DispositionAttachment with original filename

Upload Document

Upload a new document to a declaration.

curl -X POST "https://app.borderbolt.com/api/v1/declarations/12345/documents" \ -H "Authorization: Bearer your-access-token" \ -H "Accept: application/json" \ -F "file=@/path/to/invoice.pdf" \ -F "document_type=invoice" \ -F "description=Commercial invoice for shipment"

Required Scope: declarations:write

Request Body (multipart/form-data)

FieldRequiredTypeDescription
fileYesfileThe file to upload (max 50 MB)
document_typeNostringDocument type (see document types below)
descriptionNostringDescription of the document (max 500 characters)

Response

{ "data": { "id": 103, "original_filename": "invoice.pdf", "mime_type": "application/pdf", "file_size": 245760, "file_size_human": "240 KB", "document_type": "invoice", "description": "Commercial invoice for shipment", "created_at": "2026-03-25T14:00:00+00:00" }, "message": "Document uploaded successfully." }

HTTP Status: 201 Created

File Restrictions

  • Max Size: 50 MB
  • Allowed Types: PDF, Word (.doc, .docx), Excel (.xls, .xlsx), Images (JPEG, PNG, GIF, WebP), Text, CSV, XML
  • Blocked Extensions: php, phtml, php3, php4, php5, exe, sh, bat, cmd, js, vbs

Update Document Metadata

Update the document type or description of an existing document.

curl -X PUT "https://app.borderbolt.com/api/v1/declarations/12345/documents/101" \ -H "Authorization: Bearer your-access-token" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "document_type": "customs_valuation", "description": "Updated: Customs valuation document" }'

Required Scope: declarations:write

Request Body

FieldRequiredTypeDescription
document_typeNostringNew document type
descriptionNostringNew description (max 500 characters)

Response

{ "data": { "id": 101, "original_filename": "invoice-2026-001.pdf", "mime_type": "application/pdf", "file_size": 245760, "document_type": "customs_valuation", "description": "Updated: Customs valuation document", "updated_at": "2026-03-25T15:00:00+00:00" }, "message": "Document updated successfully." }

Note: You can only update metadata (document type and description). The file itself cannot be replaced. To change the file, upload a new document.

Document Types

The following document types are available:

TypeDescription
invoiceInvoice
packing_listPacking List
bill_of_ladingBill of Lading (B/L)
airway_billAirway Bill (AWB)
cmrCMR (International Consignment Note)
certificate_of_originCertificate of Origin
eur1EUR.1 (Preferential Origin Certificate)
atrA.TR (Turkey Movement Certificate)
health_certificateHealth Certificate
phytosanitaryPhytosanitary Certificate
import_permitImport Permit
export_permitExport Permit
customs_valuationCustoms Valuation Document
insuranceInsurance Document
contractContract
correspondenceCorrespondence
utbUTB (Invitation to Pay / Uitnodiging tot Betaling)
emergency_procedureEmergency Procedure Document (Noodprocedure)
sadSAD (Single Administrative Document)
otherOther

Error Responses

Declaration Not Found

{ "error": "not_found", "message": "Declaration not found." }

HTTP Status: 404

Document Not Found

{ "error": "not_found", "message": "Document not found." }

HTTP Status: 404

File Not Found in Storage

{ "error": "not_found", "message": "File not found in storage." }

HTTP Status: 404

Validation Error (Upload)

{ "error": "validation_error", "message": "The given data was invalid.", "errors": { "file": ["The file field is required."], "document_type": ["The selected document type is invalid."] } }

HTTP Status: 422

Next Steps

Last updated on