TWIN Supply Chain Docs
TutorialsSandbox scripts

Border Agency

Verify the ISN signals you receive and read the consignment data behind them.

TWIN automatically sends ISN signals to your configured endpoint when:

  • A consignment pre-notification is published
  • A consignment is despatched

Verify that your endpoint is receiving the signals from TWIN. Each signal contains the consignment's globalId — use it to retrieve the full consignment data and download the attached documents.

This assumes you've already followed Get the scripts — you have a terminal open in the unzipped folder and config.env already has your credentials.

(Optional) Save the consignment's globalId

The signal you receive carries the globalId in its payload. You can pass it as an argument every time, or save it once in the same config.env you already filled in:

open -e config.env
nano config.env

Save and exit: Ctrl+O, Enter, Ctrl+X.

notepad config.env
config.env
SANDBOX_CONSIGNMENT_GLOBAL_ID=<globalId from the signal>

Read the consignment and its documents

Still in the same terminal, same folder — if you saved the globalId in the previous step:

bash fetch-consignment.sh

Or pass the globalId directly as an argument:

bash fetch-consignment.sh <globalId>

The script retrieves the full consignment and downloads every attached document — the real files, not just metadata — into downloads/<globalId>/:

Reading as:     did:iota:0x...
Consignment:    <globalId>

✓ Consignment → downloads/<globalId>/consignment.json
✓ INV-1234 (Commercial Invoice, rev 0) → downloads/<globalId>/INV-1234-rev0.pdf
✓ PL-9 (Packing List, rev 0) → downloads/<globalId>/PL-9-rev0.pdf

Done — 2 document(s) downloaded to downloads/<globalId>/

Getting consignmentNotFound instead? It usually does not mean the consignment is missing. A consignment is only readable by you once the organisation that published it has shared it with border agencies of your country, and that sharing is set up in the TWIN web app — no script here can grant it.

Your entitlement follows the route: a consignment is yours to read when its port of exit or port of entry is in your country, and a port's country is the first two letters of its UN/LOCODE. A consignment travelling FRCQFGBFXT concerns the agencies of FR and GB, and no others.

So receiving a signal for a consignment you cannot then read means the sharing has not been set up for your country. If you are publishing from a test freight forwarder account of your own, that is yours to set.

On this page