Chemical Purchases API

Reference for ChemicalPurchaseRecord endpoints — track procurement of chemical products with costs, delivery, and quality documentation.

Endpoints

MethodPathDescription
GET/api/v1/chemical-purchasesList chemical purchase records (filtered)
GET/api/v1/chemical-purchases/{id}Get a purchase record by ID
POST/api/v1/chemical-purchasesCreate 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

ParameterTypeRequiredDescription
companyIdintegerFilter by company ID
chemicalProductIdintegerFilter by chemical product ID
supplierIdintegerFilter 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

FieldTypeRequiredDescription
chemical_product_idintegerFK to ChemicalProduct.id
supplier_idintegerFK to chemical supplier
company_idintegerCompany making the purchase
purchase_datestring (date-time)ISO 8601 purchase datetime
quantity_kgnumberQuantity in kg (must be > 0)
cost_per_kgnumberCost per kilogram (must be > 0)
total_costnumberTotal cost (auto-calculated if not provided)
currencystringISO 4217 currency code (3 letters)
delivery_datestring (date)Delivery date
purchase_order_numberstringPO reference, max 100 chars
invoice_numberstringInvoice reference, max 100 chars
batch_numberstringBatch/lot ID, max 100 chars
batch_expiry_datestring (date)Batch expiry date
warehouse_locationstringStorage location, max 255 chars
quality_certificate_numberstringQuality cert number, max 100 chars
msds_receivedbooleanWhether MSDS document was received
reach_compliantbooleanREACH compliance for this batch
notesstringNotes, max 1000 chars
internal_notesstringInternal 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