Products
GET
/products
Public
List products with filters and pagination.
Query Parameters
category_id(optional)status(optional: active, inactive, archived)q(optional, search by name or SKU)page,per_page(optional; default 1 / 20)
Example:
GET /products?category_id=1&q=tomato&page=1&per_page=20
200 OK
{
"products": [
{"id": 1, "name": "Roma Tomatoes", "sku": "ROMA-001", "category_id": 1}
],
"pagination": {
"page": 1,
"per_page": 20,
"total": 1,
"pages": 1,
"has_next": false,
"has_prev": false
}
}
GET
/products/<product_id>
Public
Get product detail plus related products in the same category.
200 OK
{
"product": {"id": 1, "name": "Roma Tomatoes", "category_id": 1},
"related": [
{"id": 2, "name": "Cherry Tomatoes", "category_id": 1}
]
}
404 Not Found
POST
/products
Admin / Employee
Create a product. Requires admin or employee. Supports multipart upload for an image file (field name: image).
Request Body (JSON)
name(required)sku(required, unique)description(optional)image(optional, multipart file; saved and URL returned)category_id(optional)status(optional: active/inactive/archived, default: active)
201 Created
400 missing required
409 SKU exists
PUT
/products/<product_id>
Admin / Employee
Update a product. Supports multipart upload for image; old image is deleted when a new one is provided.
200 OK
404 Not Found
PATCH
/products/<product_id>/status
Admin / Employee
Update product status.
200 OK
404 Not Found
DELETE
/products/<product_id>
Admin Only
Delete a product.
200 OK
404 Not Found