2026 customs changesWhat it means

API Reference

Document Upload Endpoints
CargoLint REST API.

Upload documents for extraction and checks, group them into shipments, and know what happens to each file after it arrives.

Document Upload Endpoints

Every uploaded file is stored, scanned, classified, read and checked, and lands in a shipment. This page covers sending files. To add files to a shipment you already have, use POST /shipments/{id}/documents.

Upload a document

POST /documents

Send one file per request as multipart/form-data.

Part Where Required Description
file form Yes The document file
uploadBatchId query No A GUID you choose; files uploaded with the same id are grouped into the same shipment
shipmentLabel query No A shipment reference, up to 64 characters (see How a document joins a shipment)
timeZone query No An IANA time zone such as America/Toronto; a generated shipment reference then carries that day’s date instead of the UTC date
curl -X POST "https://api.cargolint.com/api/v1/documents" \
  -H "X-API-Key: cl_YOUR_API_KEY" \
  -F "file=@invoice.pdf"

Response

200 OK:

{
  "id": "6b0f7c1e-2d1a-4a8e-9f0e-1c2b3d4e5f60",
  "fileName": "invoice.pdf",
  "status": "Processing",
  "documentType": "application/pdf",
  "createdAt": "2026-10-22T10:30:00Z",
  "shipmentId": "0c9a7b6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d",
  "reference": "Shipment-2026-10-22-004"
}
Field Description
id The document id
status Processing once the file is queued, or Uploaded if queuing has to be retried
documentType The file’s media type, read from its content. The kind of document (Invoice, AirWaybill and so on) comes later, in detectedDocumentType
shipmentId, reference The shipment the document joined

Processing runs in the background. Poll GET /documents/{id} or subscribe to webhooks to learn when it finishes.

Files CargoLint accepts

  • Formats: PDF, PNG, JPEG and TIFF. The name must end in .pdf, .png, .jpg, .jpeg, .tif or .tiff, and the content itself must be a readable file of one of those formats; a file whose content does not match is refused.
  • Size: up to 20 MB per file.
  • Refused: empty files, password-protected PDFs, and images whose dimensions are too large to process.
  • Malware scan: every upload is scanned before it is processed. A file flagged as malicious is not read and ends as Failed.
  • Language: documents must be in English, except the kinds marked multilingual in the document kinds registry, such as road and rail consignment notes. A document in another language ends as Failed, naming the language detected.

How a document joins a shipment

Every uploaded document is attached to a shipment at upload, in this order:

  1. With shipmentLabel: the open (not settled) shipment whose reference equals the label, or a new shipment with that reference.
  2. With uploadBatchId: the shipment of another document already uploaded with the same batch id.
  3. Otherwise: a new shipment with a generated reference such as Shipment-2026-10-22-004.

The shipment.document_linked webhook reports each placement.

To send a set of documents as one shipment, give them the same uploadBatchId:

BATCH_ID="550e8400-e29b-41d4-a716-446655440000"

curl -X POST "https://api.cargolint.com/api/v1/documents?uploadBatchId=$BATCH_ID" \
  -H "X-API-Key: cl_YOUR_API_KEY" -F "file=@invoice.pdf"

curl -X POST "https://api.cargolint.com/api/v1/documents?uploadBatchId=$BATCH_ID" \
  -H "X-API-Key: cl_YOUR_API_KEY" -F "file=@packing-list.pdf"

Once a shipment holds two or more active documents, CargoLint checks them against each other. See Shipment Consistency Checks.

What happens after upload

  1. Classified. CargoLint decides which kind of document the file is, among every kind in the registry.
  2. Split, if it is a pack. A PDF that holds several documents (an invoice, a packing list and a certificate in one file, for example) is split into them. Each part becomes its own document in the same shipment and batch, with splitFromDocumentId pointing to the upload. The upload itself ends with status Split, lists its parts in splitDocuments, and leaves the shipment. The document.split webhook reports the parts and their page ranges.
  3. Read, or recognized only. A kind CargoLint reads has its fields extracted and scored, and moves to PendingApproval or RequiresReview. A kind CargoLint recognizes but does not read ends as Recognized: it is kept, titled and counted as present in its shipment, with no fields and no findings.
  4. Checked. The document’s own checks run, and its shipment is evaluated again.

Within a shipment, a newer document of a kind the shipment keeps one of replaces the older one for checks. Bills of lading and air waybills are kept one per document number, so a master and a house bill both stay active. A replaced document stays attached with supersededByDocumentId set.

Usage

Each uploaded file counts as one document against the plan’s monthly allowance, including files that later fail. On the Starter plan an upload past the allowance is refused with 402. See Billing and Plans.

Documents from the Export Compliance Desk

The Export Compliance Desk uploads through this endpoint with the Desk key your organization gave it, one shipment for each of its transactions, with the transaction’s reference as shipmentLabel. Its documents never count toward your monthly allowance.

  • The Desk’s shipments are read-only for you. You see them, with their documents, report and findings, and the Desk changes them. An upload made in the app or with your organization’s API key whose shipmentLabel names one of them is refused with 409 and the code DESK_SHIPMENT_READ_ONLY, as is every other change to them.
  • The Desk’s documents have a ceiling of their own: 25 per shipment, the parts of a pack included, and 2,000 per organization in a calendar month (UTC). Every document the Desk sent counts, read or not, until it is deleted. Past the ceiling the Desk’s upload is refused with 409 before the file is kept: DESK_SHIPMENT_FULL for the shipment, DESK_MONTHLY_CEILING for the month, which lifts on the first of the next month. A pack is checked as one document when it arrives; all its parts are kept, and they count for the Desk’s next upload.

Errors

Status Body Cause
400 {"error": "No file provided"} No file part
400 {"error": "File size exceeds 20MB limit"} File too large
400 {"error": "File type not supported. Allowed types: PDF, PNG, JPG, TIFF"} File name extension not accepted
400 {"error": "File content is not a readable PDF, PNG, JPEG or TIFF."} Content does not match a supported format
400 {"error": "PDF is password protected and cannot be processed."} Encrypted PDF
400 {"error": "shipmentLabel must be 64 characters or less"} Label too long
402 {"error": "...", "code": "USAGE_LIMIT_EXCEEDED"} Starter allowance used up
409 {"error": "This shipment is settled. Re-open it to change it."} shipmentLabel names a settled shipment
409 {"error": "...", "code": "DESK_SHIPMENT_READ_ONLY"} shipmentLabel names a shipment of the Export Compliance Desk
409 {"error": "...", "code": "DESK_SHIPMENT_FULL"} The Desk key only: the shipment holds 25 of the Desk’s documents
409 {"error": "...", "code": "DESK_MONTHLY_CEILING"} The Desk key only: the organization has 2,000 of the Desk’s documents this month

Other ways in

What’s next