List Products
Get a list of products with filtering by category and search term.Authentication Required: YesRoles: admin, manager, cashier
Query Parameters
Number of products per page
Response
Soft delete timestamp (null if active)
Example
curl -X GET "https://localhost:8080/api/v1/products?page=1&limit=10&search=coffee" \
-H "Cookie: access_token=YOUR_TOKEN"
{
"message": "Products retrieved successfully",
"data": {
"products": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Espresso Coffee",
"price": 25000,
"stock": 100,
"category_id": 1,
"category_name": "Beverages",
"image_url": "https://storage.example.com/products/espresso.jpg",
"deleted_at": null
}
],
"pagination": {
"current_page": 1,
"per_page": 10,
"total_data": 1,
"total_page": 1
}
}
}
Get Product by ID
Retrieve detailed information of a specific product by its ID.Authentication Required: YesRoles: admin, manager, cashier
Path Parameters
Response
Example
curl -X GET https://localhost:8080/api/v1/products/123e4567-e89b-12d3-a456-426614174000 \
-H "Cookie: access_token=YOUR_TOKEN"
Create Product
Create a new product with multiple options.Authentication Required: YesRoles: admin, manager
Request Body
Product name (3-100 characters)
Initial stock (minimum 0)
Array of product optionsOption name (1-100 characters)
Additional price for this option (minimum 0)
Response
Created product information
Example
curl -X POST https://localhost:8080/api/v1/products \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"name": "Cappuccino",
"price": 30000,
"cost_price": 15000,
"stock": 50,
"category_id": 1,
"options": [
{
"name": "Extra Shot",
"additional_price": 5000
},
{
"name": "Oat Milk",
"additional_price": 8000
}
]
}'
{
"message": "Product created successfully",
"data": {
"id": "223e4567-e89b-12d3-a456-426614174001",
"name": "Cappuccino",
"price": 30000,
"cost_price": 15000,
"stock": 50,
"category_id": 1,
"category_name": "Beverages",
"options": [
{
"id": "323e4567-e89b-12d3-a456-426614174002",
"name": "Extra Shot",
"additional_price": 5000
},
{
"id": "423e4567-e89b-12d3-a456-426614174003",
"name": "Oat Milk",
"additional_price": 8000
}
],
"created_at": "2024-03-03T12:00:00Z"
}
}
Update Product
Update details of a specific product by its ID.Authentication Required: YesRoles: admin, manager
Path Parameters
Request Body
Product name (3-100 characters)
Stock quantity (minimum 0)
Stock change type: sale, restock, correction, return, or damage
Stock change note (max 255 characters)
Response
Updated product information
Example
curl -X PATCH https://localhost:8080/api/v1/products/223e4567-e89b-12d3-a456-426614174001 \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"price": 32000,
"stock": 75,
"change_type": "restock",
"note": "Weekly restock"
}'
Delete Product
Soft delete a product by its ID.Authentication Required: YesRoles: admin
Path Parameters
Response
Example
curl -X DELETE https://localhost:8080/api/v1/products/223e4567-e89b-12d3-a456-426614174001 \
-H "Cookie: access_token=YOUR_TOKEN"
Upload Product Image
Upload an image for a product by ID.Authentication Required: YesRoles: admin, manager
Path Parameters
Request Body (multipart/form-data)
Response
Updated product information with image URL
Example
curl -X POST https://localhost:8080/api/v1/products/223e4567-e89b-12d3-a456-426614174001/image \
-H "Cookie: access_token=YOUR_TOKEN" \
-F "image=@/path/to/product.jpg"
Get Stock History
Get stock history for a specific product with pagination.Authentication Required: YesRoles: admin, manager
Path Parameters
Query Parameters
Number of records per page
Response
Example
curl -X GET "https://localhost:8080/api/v1/products/223e4567-e89b-12d3-a456-426614174001/stock-history?page=1&limit=10" \
-H "Cookie: access_token=YOUR_TOKEN"