Skip to main content

3. Data Ingestion & Supply Chain

The following methods are available via the AgriBackup SDK for this integration stage.

List Supplier Mappings​

Retrieves all mapped suppliers for the enterprise.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.suppliers.listSuppliers();
console.log(response.data);

Register Supplier Mapping​

Binds an internal ERP Vendor ID to an official EU TRACES Operator UUID.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const enterpriseSupplierRequest = {
"vendorId": "VEND-1002",
"operatorUuid": "123e4567-e89b-12d3-a456-426614174000",
"companyName": "Acme Sourcing Ltd",
"taxId": "TAX-1234",
"countryCode": "KEN",
"parentVendorId": "VEND-1001"
};
const response = await client.suppliers.registerSupplier(enterpriseSupplierRequest);
console.log(response.data);

Invokes the [BATCH_SHIPMENT_GATEKEEPER] Hedera Smart Contract to lock a verified batch to a logistics shipment. Emits a 'shipment.linked' webhook upon blockchain consensus.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const shipmentLinkRequest = {
"batchId": "uuid-1234",
"shipmentId": "SHIP-OOCL-9988",
"billOfLading": "BOL-77665544",
"vesselName": "MSC Gulsun"
};
const response = await client.api.linkBatchToShipment(shipmentLinkRequest);
console.log(response.data);

List Verified Polygons​

Retrieves a cursor-paginated list of all verified farm boundary polygons matching the organization scope.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.polygons.getPolygons('starting_after', 'updated_after', 'limit', 'status');
console.log(response.data);

Ingest GeoJSON Polygons (Async)​

Programmatically ingest farm/production unit polygons. Returns 202 instantly. The bulk ingestion engine runs deforestation checks and fires 'polygon.verified' webhook upon completion.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const polygonIngestionRequest = {
"features": [
"{}"
]
};
const response = await client.polygons.ingestPolygons('X-Sub-Organization-ID', polygonIngestionRequest);
console.log(response.data);

List Batches​

Retrieves a cursor-paginated list of registered EUDR batches.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.batches.getBatches('starting_after', 'updated_after', 'limit');
console.log(response.data);

Register a consolidated EUDR batch (Synchronous)​

Programmatically create a new EUDR batch linked to an array of pre-verified Polygon IDs. Returns a 201 response with the batch details immediately.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const batchRegistrationRequest = {
"commodity": "COFFEE",
"countryCode": "KEN",
"hsCode": "090111",
"quantityKg": 5000.5,
"polygonIds": [
"string"
],
"vendorIds": [
"string"
]
};
const response = await client.batches.registerBatch('X-Sub-Organization-ID', batchRegistrationRequest);
console.log(response.data);

Run compliance risk assessment for an EUDR batch​

An explicit command to lock the batch, verify all attached legal documents, and run the EUDR oracle checks. Returns 202 instantly, and triggers the batch.risk_assessed webhook when finished.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.batches.assessRisk('batchId');
console.log(response.data);

Get batch by ID​

Returns the consolidated risk state and linked shipment IDs for a single EUDR batch.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.batches.getBatchById('batchId');
console.log(response.data);

Delete an EUDR batch​

Deletes a batch if it is not cryptographically linked to a shipment or TRACES NT.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.batches.deleteBatch('batchId');
console.log(response.data);

Update an EUDR batch​

Updates batch details if it is not cryptographically linked to a shipment or TRACES NT.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const batchUpdateRequest = {
"quantity": 5000.0,
"commodityDescription": "Roasted Cocoa Beans",
"hsCode": "180100",
"harvestDate": "2023-11-15"
};
const response = await client.batches.updateBatch('batchId', batchUpdateRequest);
console.log(response.data);

Get Supplier Mapping​

Retrieves the mapping for a specific internal ERP Vendor ID.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.suppliers.getSupplier('vendorId');
console.log(response.data);

Get Polygon compliance status​

Synchronously query the deterministic EUDR compliance status (PENDING, COMPLIANT, HIGH_RISK) of a specific polygon before linking it to a high-value shipment.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.polygons.getPolygonStatus('polygonId');
console.log(response.data);

Delete Polygon​

Deletes a polygon if it is not cryptographically linked to a batch or shipment.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.polygons.deletePolygon('polygonId');
console.log(response.data);

Asynchronously rollback the Hedera smart contract lock, freeing the batch for reassignment. Essential for logistics cancellations at the port.

import { AgriBackupClient } from 'agribackup';

const client = new AgriBackupClient('sk_live_...');
const response = await client.api.unlinkShipment('batchId', 'shipmentId');
console.log(response.data);