Overview
Creates a new category in the system. Categories are used to organize articles and subcategories.Authentication
This endpoint requires:- Valid JWT token in the
Authorizationheader - User must have ADMIN role
Request Body
The name of the category. Must be unique.
- Required: Yes
- Type: String
- Max Length: 255 characters
Optional description of the category.
- Required: No
- Type: String
- Max Length: 255 characters
Validation Rules
name: Required, string, maximum 255 charactersdescription: Optional (nullable), string, maximum 255 characters
Response
Indicates if the request was successful
Success message indicating the category was created
The newly created category object
Unique identifier for the category
Category name (max 255 characters)
Optional category description (max 255 characters)
Timestamp when the category was created
Timestamp when the category was last updated
Timestamp when the category was soft deleted (null for new categories)
Code Examples
Response Examples
Success Response (201 Created)
Validation Error Response (422 Unprocessable Entity)
Returned when validation fails:Unauthorized Response (401 Unauthorized)
Forbidden Response (403 Forbidden)
Returned when the authenticated user does not have ADMIN role:Error Codes
| Status Code | Description |
|---|---|
| 201 | Success - Category created |
| 401 | Unauthorized - Invalid or missing JWT token |
| 403 | Forbidden - User does not have ADMIN role |
| 422 | Validation Error - Invalid input data |
| 500 | Internal Server Error |
Notes
- The category name should be unique across the system
- Categories can have multiple subcategories and articles associated with them
- Soft deletes are enabled, so deleted categories are marked with a
deleted_attimestamp rather than being permanently removed