Product Type API
Audience: Frontend engineers managing product types and their required variants.- Base URL:
https://jethings-backend.fly.dev - Content-Type:
application/json
Conventions
- All responses are JSON.
- Errors follow standard HTTP status codes with
{ message: string }body. - Unless noted, successful responses are
200 OK. - All endpoints require authentication via Bearer token.
Get All Product Types
GET/product-types
Requires Authentication: Bearer token in Authorization header
Retrieve all product types in the system with support for pagination, search, and filtering.
Query Parameters
Success Response
Response Fields
Possible Errors
401 Unauthorized: Missing or invalid authentication token500 Internal Server Error: Server error
Example Requests
Basic Request (Default Pagination)
With Pagination
With Search
Filter by Active Status
With Sorting
Combined Filters
Get Product Type Required Variants
GET/product-types/:productTypeId/required-variants
Requires Authentication: Bearer token in Authorization header
Retrieve all required variants associated with a specific product type.
Path Parameters
Success Response
Response Fields
Possible Errors
401 Unauthorized: Missing or invalid authentication token404 Not Found: Product type not found500 Internal Server Error: Server error
Example Request
Create Product Type with Variants
POST/product-types
Requires Authentication: Bearer token in Authorization header
Create a new product type along with its required variants in a single transaction.
Request Body
Request Body Fields
Required Variant Object
Success Response
Response Fields
Possible Errors
400 Bad Request: Invalid request data or validation errors401 Unauthorized: Missing or invalid authentication token409 Conflict: Product type code already exists500 Internal Server Error: Server error
Example Request
Add Required Variants to Product Type
POST/product-types/:productTypeId/required-variants
Requires Authentication: Bearer token in Authorization header
Add one or more required variants to an existing product type.
Path Parameters
Request Body
Request Body Fields
Required Variant Object
Success Response
Response Fields
Possible Errors
400 Bad Request: Invalid request data or validation errors401 Unauthorized: Missing or invalid authentication token404 Not Found: Product type not found500 Internal Server Error: Server error
Example Request
DTOs Overview
GetProductTypesDto (Query Parameters)
PaginatedProductTypesResponseDto
ProductTypeResponseDto
CreateProductTypeWithVariantsDto
AddRequiredVariantToProductTypeDto
CreateRequiredVariantDto
RequiredVariantResponse
Business Logic
Product Type Creation Flow
- User creates a product type with multilingual names (English, French, Arabic)
- Product type is created with
isActive: trueby default - Required variants can be created in the same transaction
- Each required variant can have optional allowed values to restrict input
Required Variants
- Required variants define what attributes must be specified when creating products of this type
- Examples: Size, Color, Material, Pattern, etc.
allowedValuescan be:- An array of specific values (e.g.,
["S", "M", "L"]) - restricts to these values only nullor omitted - allows any value to be entered
- An array of specific values (e.g.,
- Variants are linked to product types through a many-to-many relationship
Transaction Safety
- Creating a product type with variants uses a database transaction
- If any variant creation fails, the entire operation is rolled back
- Adding variants to an existing product type also uses transactions for consistency
Use Cases
- Clothing: Size, Color, Material
- Electronics: Model, Storage Capacity, Color
- Food Items: Weight, Unit, Expiry Date
- Custom Products: Any custom attributes defined by the business
Error Responses
Common Error Codes
400 Bad Request: Invalid request data or validation errors401 Unauthorized: Missing or invalid authentication token404 Not Found: Product type not found409 Conflict: Product type code already exists500 Internal Server Error: Server error