Supplier Products
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/supplier-products | Create a supplier product |
PATCH | /api/supplier-products/{id} | Update a supplier product |
POST | /api/supplier-products/bulk | Bulk upsert supplier products |
POST /api/supplier-products
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Product name |
sku | string | ✅ | Stock-keeping unit (unique per supplier) |
supplier_id | integer | ✅ | FK to Supplier.id |
description | string | ❌ | Optional product description |
composition | string | ❌ | Material composition |
unit_of_measure | string | ❌ | METERS, KG, PIECES, ROLLS. Default: KG (New in v1.1.0) |
product_origin_country | string | ❌ | ISO 3166-1 alpha-2 where product is made (e.g. IT, CN) (New in v1.1.0) |
raw_material_origin_country | string | ❌ | ISO 3166-1 alpha-2 where raw material originates (New in v1.1.0) |
quantity_available | number | ❌ | Current stock quantity (≥ 0) (New in v1.1.0) |
lead_time_days | integer | ❌ | Procurement lead time in days (≥ 0) (New in v1.1.0) |
unit_cost | number | ❌ | Purchase price per unit |
currency | string | ❌ | ISO 4217 currency code |
reach_compliant | boolean | ❌ | REACH compliance flag |
certifications | array | ❌ | List of certification strings |
product_weight_kg | number | ❌ | Product weight in kg (must be positive) |
gots_certified | boolean | ❌ | GOTS certification |
available | boolean | ❌ | Whether the product is available. Default: true |
Note
v1.1.0 — product_origin_country and raw_material_origin_country are validated against the full ISO 3166-1 alpha-2 country list. Invalid codes return 400 Bad Request.
Shell
curl -X POST http://localhost:8080/api/supplier-products \-H "Content-Type: application/json" \-H "X-User-Id: 1" \-H "X-API-Key: your-api-key" \-d '{"name": "Cotton Fabric 200gsm","sku": "FAB-CN-200","supplier_id": 1,"unit_of_measure": "METERS","unit_cost": 3.50,"currency": "EUR","reach_compliant": true,"product_origin_country": "IN","raw_material_origin_country": "IN","quantity_available": 2500.0,"lead_time_days": 45,"certifications": ["GOTS", "OCS"]}'
JavaScript
const resp = await fetch('/api/supplier-products', {method: 'POST',headers: {'Content-Type': 'application/json','X-User-Id': '1','X-API-Key': 'your-api-key'},body: JSON.stringify({name: 'Cotton Fabric 200gsm',sku: 'FAB-CN-200',supplier_id: 1,unit_of_measure: 'METERS',product_origin_country: 'IN',raw_material_origin_country: 'IN',quantity_available: 2500.0,lead_time_days: 45})});
POST /api/supplier-products/bulk
Upserts by (sku, supplier_id) combination.
JSON
{"items": [{"name": "Cotton Fabric 200gsm","sku": "FAB-001","supplier_id": 1,"unit_of_measure": "METERS","product_origin_country": "IN","quantity_available": 2500.0,"lead_time_days": 45},{"name": "Polyester Lining","sku": "FAB-002","supplier_id": 1,"unit_of_measure": "METERS","product_origin_country": "CN"}]}
UnitOfMeasure Enum
New in v1.1.0
| Value | Meaning | Typical Use |
|---|---|---|
KG | Kilograms — default | Raw materials sold by weight |
METERS | Linear metres | Fabric, ribbon, tape |
PIECES | Individual items | Buttons, zippers, accessories |
ROLLS | Full rolls | Fabric reels, paper |
Company Products
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/company-products | Create a company product |
PATCH | /api/company-products/{id} | Update a company product |
POST | /api/company-products/bulk | Bulk upsert company products |
POST /api/company-products
All fields from BaseProduct apply here as well, including the new v1.1.0 fields.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ✅ | Product name |
sku | string | ✅ | Stock-keeping unit (unique) |
unit_of_measure | string | ❌ | METERS, KG, PIECES, ROLLS. Default: KG (New in v1.1.0) |
product_origin_country | string | ❌ | ISO 3166-1 alpha-2 (New in v1.1.0) |
raw_material_origin_country | string | ❌ | ISO 3166-1 alpha-2 (New in v1.1.0) |
quantity_available | number | ❌ | Current stock quantity (≥ 0) (New in v1.1.0) |
lead_time_days | integer | ❌ | Lead time in days (≥ 0) (New in v1.1.0) |
barcode | string | ❌ | EAN / GTIN barcode |
unit_sale_price | number | ❌ | Selling price per unit |
sustainability_score | integer | ❌ | ESG score 0–100 |
recycled_content_percent | number | ❌ | Percentage of recycled content |
available | boolean | ❌ | Whether the product is available. Default: true |
Shell
curl -X POST http://localhost:8080/api/company-products \-H "Content-Type: application/json" \-H "X-User-Id: 1" \-H "X-API-Key: your-api-key" \-d '{"name": "Eco Tote Bag","sku": "TOTE-ECO-001","barcode": "8032123456789","unit_of_measure": "PIECES","unit_sale_price": 12.90,"sustainability_score": 85,"recycled_content_percent": 40.0,"product_origin_country": "TR","raw_material_origin_country": "IN","quantity_available": 1500.0,"lead_time_days": 30}'
JavaScript
const resp = await fetch('/api/company-products', {method: 'POST',headers: {'Content-Type': 'application/json','X-User-Id': '1','X-API-Key': 'your-api-key'},body: JSON.stringify({name: 'Eco Tote Bag',sku: 'TOTE-ECO-001',unit_of_measure: 'PIECES',sustainability_score: 85,product_origin_country: 'TR',raw_material_origin_country: 'IN',quantity_available: 1500.0,lead_time_days: 30})});