Skip to content

Product Sub Category

Create, update, list and remove product subcategories linked to parent product categories.


Authentication

  • Public: GET /api/v1/product-subcategories requires no authentication.
  • Admin: All mutating endpoints (POST, PUT, DELETE) require an authenticated ADMIN account with catalog:manage permission:
Authorization: Bearer <admin_access_token>

Product Sub Category Endpoints

Method Endpoint Description Auth Required
GET /api/v1/product-subcategories Retrieve subcategories for a category Public
POST /api/v1/admin/product-subcategories Create a new product subcategory Admin + catalog:manage
PUT /api/v1/admin/product-subcategories/{id} Update an existing subcategory name Admin + catalog:manage
DELETE /api/v1/admin/product-subcategories/{id} Delete a product subcategory Admin + catalog:manage

Endpoint Details

1. Get Product Sub Categories

GET /api/v1/product-subcategories Public / No Auth Required

Retrieves all subcategories associated with a mandatory parent category UUID.

Query Parameters

Parameter Type Required Description
categoryId string Required UUID of the parent product category
page / offset integer Optional Page number (default: 1) or offset (default: 0)
perPage / limit integer Optional Items per page (default: 20)

Request Examples

curl -X GET 'http://localhost:8080/api/v1/product-subcategories?categoryId=b8ccc13f-e118-4540-8e9e-5eaa8028cb4f&page=1&perPage=20' \
  -H 'Accept: application/json'
const res = await fetch("http://localhost:8080/api/v1/product-subcategories?categoryId=b8ccc13f-e118-4540-8e9e-5eaa8028cb4f");
const subCategories = await res.json();

Response

[
  {
    "id": "751cef10-f98a-4ecc-ae03-4173830a626d",
    "categoryId": "b8ccc13f-e118-4540-8e9e-5eaa8028cb4f",
    "name": "Paper"
  }
]
{
  "message": "Missing required query parameter: categoryId"
}

2. Create Product Sub Category

POST /api/v1/admin/product-subcategories Admin Token Required

Creates a new subcategory linked to an existing parent category.

Request Body Parameters

Parameter Type Required Description
categoryId string Required UUID of the parent category
name string Required Subcategory display title

Request Examples

curl -X POST 'http://localhost:8080/api/v1/admin/product-subcategories' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <admin_access_token>' \
  -d '{
    "categoryId": "b8ccc13f-e118-4540-8e9e-5eaa8028cb4f",
    "name": "Notebooks"
  }'

Response

{
  "id": "751cef10-f98a-4ecc-ae03-4173830a626d",
  "categoryId": "b8ccc13f-e118-4540-8e9e-5eaa8028cb4f",
  "name": "Notebooks"
}

3. Update Product Sub Category

PUT /api/v1/admin/product-subcategories/{id} Admin Token Required

Updates the name of an existing product subcategory. The new name can be passed as a JSON body parameter or URL query parameter.

Path & Query Parameters

Parameter Type Required Description
id string (path) Required UUID of the subcategory to update
name string (query/body) Required Updated name

Request Examples

curl -X PUT 'http://localhost:8080/api/v1/admin/product-subcategories/751cef10-f98a-4ecc-ae03-4173830a626d?name=Premium+Paper' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer <admin_access_token>'

Response

{
  "id": "751cef10-f98a-4ecc-ae03-4173830a626d",
  "categoryId": "b8ccc13f-e118-4540-8e9e-5eaa8028cb4f",
  "name": "Premium Paper"
}

4. Delete Product Sub Category

DELETE /api/v1/admin/product-subcategories/{id} Admin Token Required

Permanently removes a product subcategory.

Request Examples

curl -X DELETE 'http://localhost:8080/api/v1/admin/product-subcategories/751cef10-f98a-4ecc-ae03-4173830a626d' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer <admin_access_token>'

Response

{
  "message": "Subcategory deleted successfully"
}

Error Handling

Standard Error Responses

For error payload structures, common status codes (400, 401, 403, 404), and validation failure schemas, see the Error Handling & Status Codes Guide.