Inventory API
Stock tracking and inventory movement endpoints.
Inventory API
The Inventory API provides endpoints for tracking stock levels, recording inventory movements, and managing inventory adjustments across warehouses.
Endpoints
GET /api/inventory
Retrieve inventory levels across all warehouses.
Query Parameters:
warehouse_id(string): Filter by warehouseproduct_id(string): Filter by productlow_stock(boolean): Show only low stock itemsout_of_stock(boolean): Show only out of stock items
Response:
{
"data": [
{
"id": "inv_001",
"product": {
"id": "prod_123",
"name": "Smart Widget",
"sku": "SW-001"
},
"warehouse": {
"id": "wh_789",
"name": "Main Warehouse"
},
"quantity_on_hand": 150,
"quantity_allocated": 5,
"quantity_available": 145,
"reorder_point": 20,
"max_stock_level": 500,
"last_counted": "2024-01-15T10:00:00Z"
}
]
}
POST /api/inventory/movements
Record inventory movements (stock in/out/adjustments).
Request Body:
{
"product_id": "prod_123",
"warehouse_id": "wh_789",
"movement_type": "in",
"quantity": 50,
"reference_type": "purchase_order",
"reference_id": "po_456",
"notes": "Received from Supplier ABC",
"cost_per_unit": 25.00
}
Movement Types:
in: Stock receivedout: Stock shipped/soldadjustment: Manual adjustmenttransfer: Inter-warehouse transfer
Response:
{
"data": {
"id": "mov_789",
"product_id": "prod_123",
"warehouse_id": "wh_789",
"movement_type": "in",
"quantity": 50,
"balance_after": 200,
"reference_type": "purchase_order",
"reference_id": "po_456",
"notes": "Received from Supplier ABC",
"cost_per_unit": 25.00,
"created_at": "2024-01-15T15:30:00Z"
}
}
GET /api/inventory/movements
Retrieve inventory movement history.
Query Parameters:
product_id(string): Filter by productwarehouse_id(string): Filter by warehousemovement_type(string): Filter by movement typestart_date(string): Start date (ISO format)end_date(string): End date (ISO format)page(number): Page numberlimit(number): Items per page
Response:
{
"data": [
{
"id": "mov_789",
"product": {
"id": "prod_123",
"name": "Smart Widget",
"sku": "SW-001"
},
"warehouse": {
"id": "wh_789",
"name": "Main Warehouse"
},
"movement_type": "in",
"quantity": 50,
"balance_before": 150,
"balance_after": 200,
"reference_type": "purchase_order",
"reference_id": "po_456",
"notes": "Received from Supplier ABC",
"created_at": "2024-01-15T15:30:00Z",
"created_by": {
"id": "user_123",
"name": "John Doe"
}
}
],
"meta": {
"total": 500,
"page": 1,
"limit": 20,
"hasMore": true
}
}
POST /api/inventory/adjustments
Perform bulk inventory adjustments.
Request Body:
{
"adjustments": [
{
"product_id": "prod_123",
"warehouse_id": "wh_789",
"actual_quantity": 195,
"reason": "Physical count adjustment"
},
{
"product_id": "prod_124",
"warehouse_id": "wh_789",
"actual_quantity": 85,
"reason": "Damaged goods removal"
}
]
}
Response:
{
"data": {
"adjustments_processed": 2,
"total_adjustments": 2,
"adjustments": [
{
"id": "adj_001",
"product_id": "prod_123",
"warehouse_id": "wh_789",
"quantity_before": 200,
"quantity_after": 195,
"adjustment": -5,
"reason": "Physical count adjustment",
"created_at": "2024-01-15T16:00:00Z"
}
]
}
}
GET /api/inventory/analytics
Get inventory analytics and insights.
Query Parameters:
period(string): Time period (7d, 30d, 90d, 1y)warehouse_id(string): Filter by warehouse
Response:
{
"data": {
"overview": {
"total_products": 1250,
"total_stock_value": 125000.00,
"low_stock_items": 25,
"out_of_stock_items": 12
},
"trends": {
"stock_in": 5000,
"stock_out": 4500,
"adjustments": 50
},
"top_movers": [
{
"product_id": "prod_123",
"product_name": "Smart Widget",
"movement_count": 45,
"total_quantity": 2250
}
],
"low_stock_alerts": [
{
"product_id": "prod_456",
"product_name": "Basic Widget",
"current_stock": 15,
"reorder_point": 20,
"warehouse": "Main Warehouse"
}
]
}
}