Product Colour Service
Overview
The Product Colour service manages colour variants that can be assigned to products.
It is used to:
- define available colour options
- provide visual representation via swatch images
- enable colour-based filtering and selection in frontend applications
This service manages colour definitions only. It does not assign colours to products directly.
All operations are tenant-aware and all state-changing actions are audited.
Endpoints
GET
/api/v1/ProductColour/GetAllProductColour
Returns all product colours filtered by active status.
Query parameters:
isActive(bool, required)
Behavior:
- Returns only colours matching the provided
isActivevalue - Returns
404if no colours match the filter
Authorization:
- Requires Bearer Token
GET
/api/v1/ProductColour/GetProductColourById/{id}
Returns a single product colour by its identifier.
Behavior:
- Looks up colour by ID
- Returns
404if the colour does not exist
Authorization:
- Requires Bearer Token
GET
/api/v1/ProductColour/GetProductColourByCode/{code}
Returns a single product colour by its unique code.
Behavior:
- Looks up colour by
Code - Colour codes are unique per tenant
- Returns
404if no colour matches the provided code
Authorization:
- Requires Bearer Token
POST
/api/v1/ProductColour/AddNewProductColour
Creates a new product colour.
Request body:
Code(string, required)Description(string, required)ImageSwatchURL(string, required, absolute URL)IsActive(bool, optional)CreatedAt(DateTime, optional)
Behavior:
- Validates required fields
- Validates
ImageSwatchURLformat - Prevents duplicate colour codes per tenant
- If
IsActiveis not provided, it is stored asfalse - If
CreatedAtis not provided, current UTC time is used - Successful creation writes an audit log entry
Errors:
- Returns
400if:- required fields are missing
- colour code already exists
ImageSwatchURLis invalid
Authorization:
- Requires Bearer Token
PUT
/api/v1/ProductColour/UpdateProductColourById/{id}
Updates an existing product colour.
Request:
- Colour ID is taken from the route
- Body must include
Code,Description,ImageSwatchURL IsActiveis optional
Behavior:
- All required fields must be present
- Only provided fields are updated
CreatedAtis not modified- Successful update writes an audit log entry
Errors:
- Returns
400if:- validation -
- colour does not exist
Authorization:
- Requires Bearer Token
DELETE
/api/v1/ProductColour/DeleteProductColourById/{id}
Deletes a product colour by its identifier.
Behavior:
- Performs a hard delete
- Record is permanently removed from the database
- Successful deletion writes an audit log entry
Errors:
- Returns
400if colour does not exist
Authorization:
- Requires Bearer Token
Notes
- This service manages colour definitions only
- No product assignments are handled here
- Deletions are permanent (hard delete)
- Validation is enforced in the service layer
- All state-changing operations are audited
- Internal errors are logged and not exposed to API consumers