Bulk Upsert Pattern

Efficiently synchronise hundreds of records using the bulk upsert endpoints in every domain module.

Overview

Every domain module exposes a /bulk endpoint. The upsert key differs per domain:

ResourceUpsert Key
Suppliername
SupplierProduct(sku, supplier_id)
CompanyProductsku
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, requests
def 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.