Products
Create Product
Create a new product (admin only)
POST
Create Product
Overview
This endpoint allows administrators to create a new product in the catalog. It requires admin authentication and a product image upload.Endpoint
Authentication
Required: Admin role This endpoint requires a valid JWT token with admin privileges. Include the token in the Authorization header:Request Body
This endpoint acceptsmultipart/form-data format due to the required image upload.
Product name
Product description
Product price (maximum 2 decimal places)
Available stock quantity (minimum: 0)
ID of the category this product belongs to (must be >= 1 if provided)
Product image file (uploaded as multipart/form-data with field name ‘image’)
Validation Rules
name: Must be a valid stringdescription: Must be a valid stringprice: Must be a number with maximum 2 decimal placesstock: Must be an integer with minimum value of 0categoryId: If provided, must be an integer >= 1image: Required file field - the endpoint will return a 400 error if missing
Response
Returns the created product object.Unique identifier for the newly created product
Product name
Product description
Product price (decimal with 2 decimal places)
URL to the uploaded product image
Available stock quantity
ID of the category this product belongs to
Timestamp when the product was created
Timestamp when the product was last updated
Example Request
Example Response
201 Created
Error Responses
Missing Image
400 Bad Request
Validation Error
400 Bad Request
Unauthorized
401 Unauthorized
Forbidden (Non-Admin User)
403 ForbiddenCreate Product