TWIN Supply Chain Docs
TutorialsRun seed scripts

Run seed scripts

Populate a local node with consignments, events, and documents using the bundled seed scripts.

The seed scripts publish test data through the data-space connector. Use them to populate a local node without crafting REST calls by hand. You can find the full source in the Script source page.

Start a local node

pnpm install
cp apps/supply-chain-node/.env.example-local apps/supply-chain-node/.env
pnpm supply-chain-node bootstrap
pnpm supply-chain-node dev

Configure environment variables

The scripts read from apps/supply-chain-node/.env. All required variables ship with defaults in .env.example-local.

VariableDescription
SUPPLY_CHAIN_HOSTNode host, e.g. localhost
SUPPLY_CHAIN_PORTNode port, e.g. 3000
SUPPLY_CHAIN_TENANT_API_KEYSent as x-api-key
SUPPLY_CHAIN_ADMIN_USER_NAMEAdmin email
SUPPLY_CHAIN_ADMIN_USER_PASSWORDAdmin password

Run a script

Run without arguments for an interactive menu:

pnpm supply-chain-node:seed

Or pass the script name directly:

pnpm supply-chain-node:seed consignmentsCreate
ScriptWhat it does
consignmentsCreatePublishes a single consignment
consignmentsCreateWithEventsPublishes 5 consignments covering the full lifecycle with events
seedDocumentsAttaches documents to an existing consignment
seedDocumentsForNewConsignmentCreates a consignment and immediately attaches documents
createManagedLocationsRegisters port / border locations for a location operator
odrlPoliciesRegisterRegisters ODRL policies to authorise ISN and notifications

Script reference

consignmentsCreate — single consignment

Publishes a single consignment using the canonical UNECE payload with a freshly generated INT-<8 hex> identifier.

pnpm supply-chain-node:seed consignmentsCreate
  1. Acquires an authenticated client.
  2. Builds the payload: spreads supplyChainConsignmentPayload and overrides identifier.
  3. POST /supply-chain/consignments — prints the new consignment AIG id.

consignmentsCreateWithEvents — full lifecycle

Publishes 5 consignments covering the complete supply-chain lifecycle with realistic events.

pnpm supply-chain-node:seed consignmentsCreateWithEvents
#LabelEvents
1Planned for departurePreNotification
2Despatched with carrierPreNotification → Despatched → CarrierBooking
3At exit — operator matched+ IssuedDocument → OnwardSharing → AtLocationOfExit → LocationOperatorMatch
4In transit — at entry location+ LeftLocationOfExit → AtLocationOfEntry
5Delivered — full journeyComplete chain through ArrivedAtFinalDestination

A Despatched event combined with consignmentUpdate triggers the ISN despatch signal.

seedDocuments — attach to existing consignment

Upserts documents to an existing consignment. Verifies the consignment exists before attaching.

pnpm supply-chain-node:seed seedDocuments <CONSIGNMENT_ID> path/to/documents.json
pnpm supply-chain-node:seed seedDocuments <CONSIGNMENT_ID> '[{...}]'

Minimum document shape:

{
  "@context": "https://vocabulary.uncefact.org/unece-context-D23B.jsonld",
  "type": "Document",
  "identifier": "INV-2026-001",
  "versionId": "2026-06-11T10:00:00Z",
  "documentTypeCode": "unece:DocumentCodeList#380",
  "issueDateTime": "2026-06-11T10:00:00Z",
  "uRIId": "",
  "attachmentPath": "./fixtures/invoice.pdf"
}

attachmentPath is resolved relative to the JSON file (or cwd for inline JSON) and base64-encoded into attachmentBinaryObject before the API call.

seedDocumentsForNewConsignment — create + attach

Creates a fresh consignment and immediately attaches documents to it.

pnpm supply-chain-node:seed seedDocumentsForNewConsignment apps/supply-chain-node/scripts/seed/documents.json

Use this when you need an isolated consignment with known documents — for example to demo the consignment detail page without affecting existing data.

createManagedLocations — register locations

Registers managed locations for a location operator. Required before the node can match carrier bookings.

pnpm supply-chain-node:seed createManagedLocations <ORG_ID> '[{"operator":"YourOperator","locationName":"Dover","locationId":"GBDVR","active":true}]'

<ORG_ID> is the organisation DID (the org claim in the JWT).

odrlPoliciesRegister — authorise notifications

Registers ODRL read policies for ISN (border agency) and location operator notifications. Without these the node suppresses all notifications silently.

pnpm supply-chain-node:seed odrlPoliciesRegister

Troubleshooting

SymptomFix
Missing required env vars: …Copy .env.example-local to .env
Login failed: 401Wrong admin credentials — re-bootstrap
Consignment not found: <id>The id passed to seedDocuments does not exist for this tenant
Document N must include attachmentPath or attachmentBinaryObjectAdd attachmentPath or a base64 attachmentBinaryObject

On this page