Products API

Reference for SupplierProduct and CompanyProduct REST endpoints, including origin country tracking, logistics fields, and the UnitOfMeasure enum.

Supplier Products

Endpoints

MethodPathDescription
POST/api/v1/supplier/productsCreate a supplier product
PATCH/api/v1/supplier/products/{id}Update a supplier product
POST/api/v1/supplier/products/bulkBulk upsert supplier products

POST /api/v1/supplier/products

Request Body

FieldTypeRequiredDescription
namestringProduct name
codestringProduct code
categorystringProduct category
subcategorystringProduct subcategory
supplier_idintegerFK to Supplier.id
descriptionstringProduct description
compositionstringMaterial composition
technical_specsstringTechnical specifications
unit_of_measurestringMETERS, KG, PIECES, ROLLS. Default: KG
product_origin_countrystringISO 3166-1 alpha-2 where product is made
raw_material_origin_countrystringISO 3166-1 alpha-2 where raw material originates
quantity_availablenumberCurrent stock quantity (≥ 0)
lead_time_daysintegerProcurement lead time in days (≥ 0)
price_per_unitnumberPurchase price per unit
currencystringISO 4217 currency code
product_weight_kgnumberProduct weight in kg (must be positive)
minimum_ordernumberMinimum order quantity
gots_certifiedbooleanGOTS certification
grs_certifiedbooleanGRS certification
oeko_tex_certifiedbooleanOEKO-TEX certification
cradle_to_cradle_certifiedbooleanCradle to Cradle certification
better_cotton_certifiedbooleanBetter Cotton certification
other_certificationsstringOther certifications
recycled_content_percentnumberPercentage of recycled content
organic_content_percentnumberPercentage of organic content
sustainability_notesstringSustainability notes
availablebooleanWhether the product is available. Default: true
metadataobjectArbitrary JSON key-value pairs
Note

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/v1/supplier/products?userId=1" \
-H "Content-Type: application/json" \
-d '{
"name": "Cotton Fabric 200gsm",
"code": "FAB-CN-200",
"supplier_id": 1,
"unit_of_measure": "METERS",
"price_per_unit": 3.50,
"currency": "EUR",
"product_origin_country": "IN",
"raw_material_origin_country": "IN",
"quantity_available": 2500.0,
"lead_time_days": 45,
"gots_certified": true
}'
JavaScript
const resp = await fetch('/api/v1/supplier/products?userId=1', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Cotton Fabric 200gsm',
code: '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/v1/supplier/products/bulk

Upserts by (code, supplier_id) combination.

JSON
{
"items": [
{
"name": "Cotton Fabric 200gsm",
"code": "FAB-001",
"supplier_id": 1,
"unit_of_measure": "METERS",
"product_origin_country": "IN",
"quantity_available": 2500.0,
"lead_time_days": 45
},
{
"name": "Polyester Lining",
"code": "FAB-002",
"supplier_id": 1,
"unit_of_measure": "METERS",
"product_origin_country": "CN"
}
]
}

UnitOfMeasure Enum

ValueMeaningTypical Use
KGKilograms — defaultRaw materials sold by weight
METERSLinear metresFabric, ribbon, tape
PIECESIndividual itemsButtons, zippers, accessories
ROLLSFull rollsFabric reels, paper

Company Products

Endpoints

MethodPathDescription
POST/api/v1/company/productsCreate a company product
PATCH/api/v1/company/products/{id}Update a company product
POST/api/v1/company/products/bulkBulk upsert company products

POST /api/v1/company/products

All fields from BaseProduct apply here as well. Company products include additional fields for retail and sustainability scoring.

Additional Fields

FieldTypeRequiredDescription
namestringProduct name
codestringProduct code
unit_of_measurestringMETERS, KG, PIECES, ROLLS. Default: KG
product_origin_countrystringISO 3166-1 alpha-2
raw_material_origin_countrystringISO 3166-1 alpha-2
quantity_availablenumberCurrent stock quantity (≥ 0)
lead_time_daysintegerLead time in days (≥ 0)
availablebooleanWhether the product is available. Default: true
metadataobjectArbitrary JSON key-value pairs
Shell
curl -X POST "http://localhost:8080/api/v1/company/products?userId=1" \
-H "Content-Type: application/json" \
-d '{
"name": "Eco Tote Bag",
"code": "TOTE-ECO-001",
"unit_of_measure": "PIECES",
"product_origin_country": "TR",
"raw_material_origin_country": "IN",
"quantity_available": 1500.0,
"lead_time_days": 30,
"recycled_content_percent": 40.0,
"sustainability_notes": "Made from recycled PET bottles"
}'
JavaScript
const resp = await fetch('/api/v1/company/products?userId=1', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'Eco Tote Bag',
code: 'TOTE-ECO-001',
unit_of_measure: 'PIECES',
product_origin_country: 'TR',
raw_material_origin_country: 'IN',
quantity_available: 1500.0,
lead_time_days: 30
})
});