Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/v1/chemical-purchases | List chemical purchase records (filtered) |
GET | /api/v1/chemical-purchases/{id} | Get a purchase record by ID |
POST | /api/v1/chemical-purchases | Create a chemical purchase record |
PATCH | /api/v1/chemical-purchases/{id} | Update a chemical purchase record |
DELETE | /api/v1/chemical-purchases/{id} | Delete a chemical purchase record |
GET /api/v1/chemical-purchases
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId | integer | ❌ | Filter by company ID |
chemicalProductId | integer | ❌ | Filter by chemical product ID |
supplierId | integer | ❌ | Filter by supplier ID |
Shell
curl "http://localhost:8080/api/v1/chemical-purchases?companyId=1&supplierId=5"curl "http://localhost:8080/api/v1/chemical-purchases?chemicalProductId=42"
JavaScript
const records = await fetch('/api/v1/chemical-purchases?companyId=1').then(r => r.json());
POST /api/v1/chemical-purchases
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
chemical_product_id | integer | ✅ | FK to ChemicalProduct.id |
supplier_id | integer | ✅ | FK to chemical supplier |
company_id | integer | ✅ | Company making the purchase |
purchase_date | string (date-time) | ✅ | ISO 8601 purchase datetime |
quantity_kg | number | ✅ | Quantity in kg (must be > 0) |
cost_per_kg | number | ✅ | Cost per kilogram (must be > 0) |
total_cost | number | ❌ | Total cost (auto-calculated if not provided) |
currency | string | ✅ | ISO 4217 currency code (3 letters) |
delivery_date | string (date) | ❌ | Delivery date |
purchase_order_number | string | ❌ | PO reference, max 100 chars |
invoice_number | string | ❌ | Invoice reference, max 100 chars |
batch_number | string | ❌ | Batch/lot ID, max 100 chars |
batch_expiry_date | string (date) | ❌ | Batch expiry date |
warehouse_location | string | ❌ | Storage location, max 255 chars |
quality_certificate_number | string | ❌ | Quality cert number, max 100 chars |
msds_received | boolean | ❌ | Whether MSDS document was received |
reach_compliant | boolean | ❌ | REACH compliance for this batch |
notes | string | ❌ | Notes, max 1000 chars |
internal_notes | string | ❌ | Internal notes, max 1000 chars |
Shell
curl -X POST "http://localhost:8080/api/v1/chemical-purchases?userId=1" \-H "Content-Type: application/json" \-d '{"chemical_product_id": 42,"supplier_id": 5,"company_id": 1,"purchase_date": "2025-09-15T09:00:00","quantity_kg": 250.0,"cost_per_kg": 12.50,"currency": "EUR","purchase_order_number": "PO-CHEM-2025-001","batch_number": "BATCH-RB19-2025-09","batch_expiry_date": "2027-09-15","warehouse_location": "Warehouse A - Shelf 12","msds_received": true,"reach_compliant": true}'
JavaScript
const resp = await fetch('/api/v1/chemical-purchases?userId=1', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({chemical_product_id: 42,supplier_id: 5,company_id: 1,purchase_date: '2025-09-15T09:00:00',quantity_kg: 250.0,cost_per_kg: 12.50,currency: 'EUR',batch_number: 'BATCH-RB19-2025-09',msds_received: true,reach_compliant: true})});
Response 201 Created
JSON
{"id": 1,"chemical_product_id": 42,"supplier_id": 5,"user_id": 1,"company_id": 1,"purchase_date": "2025-09-15T09:00:00","quantity_kg": 250.0,"cost_per_kg": 12.50,"total_cost": 3125.00,"currency": "EUR","delivery_date": null,"purchase_order_number": "PO-CHEM-2025-001","invoice_number": null,"batch_number": "BATCH-RB19-2025-09","batch_expiry_date": "2027-09-15","warehouse_location": "Warehouse A - Shelf 12","quality_certificate_number": null,"msds_received": true,"reach_compliant": true,"notes": null,"internal_notes": null,"created_at": "2025-09-15T09:12:00","updated_at": "2025-09-15T09:12:00"}
PATCH /api/v1/chemical-purchases/{id}
Partially updates a chemical purchase record. Only the fields present in the request body are updated.
Shell
curl -X PATCH "http://localhost:8080/api/v1/chemical-purchases/1?userId=1" \-H "Content-Type: application/json" \-d '{"delivery_date": "2025-09-20","invoice_number": "INV-CHEM-2025-4521","quality_certificate_number": "QC-2025-00042"}'
DELETE /api/v1/chemical-purchases/{id}
Deletes a chemical purchase record.
Shell
curl -X DELETE http://localhost:8080/api/v1/chemical-purchases/1
Response: 204 No Content