Overview
Every domain module exposes a /bulk endpoint. The upsert key differs per domain:
| Resource | Upsert Key |
|---|---|
Supplier | name |
SupplierProduct | (sku, supplier_id) |
CompanyProduct | sku |
SupplierPurchaseRecord | (supplier_id, batch_number) if provided, else (supplier_id, supplier_product_id, purchase_date) |
ProcessingStage | (traceability_id, stage_order) |
Python: Sync Suppliers from CSV
Python
import csv, requestsdef sync_suppliers(csv_path: str):with open(csv_path) as f:items = [{"name": row["SupplierName"],"country": row["CountryCode"],"category": row["Category"],"reach_compliant": row["REACH"] == "Y"}for row in csv.DictReader(f)]result = requests.post("http://localhost:8080/api/suppliers/bulk",headers={"X-User-Id": "1", "X-API-Key": "your-api-key"},json={"items": items}).json()print(f"Created: {result['created']}, Updated: {result['updated']}, Failed: {result['failed']}")
Response Schema
JSON
{"created": 5,"updated": 2,"failed": 1,"errors": ["Item at index 3: name must not be blank"]}
Warning
Individual failures do not abort the batch. If you need all-or-nothing semantics use individual POST requests with client-side retry.