Skip to main content
PUT
/
subcategories
/
{id}
curl --location --request PUT 'https://api.yourapp.com/subcategories/1' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "name": "Premium Smartphones",
  "description": "High-end mobile phones and accessories"
}'
{
  "success": true,
  "message": "Subcategory updated successfully",
  "data": {
    "subcategory": {
      "id": 1,
      "name": "Premium Smartphones",
      "description": "High-end mobile phones and accessories",
      "category": {
        "id": 1,
        "name": "Electronics",
        "description": "Electronic devices and components"
      },
      "created_at": "2024-03-08T09:15:00.000000Z",
      "updated_at": "2024-03-08T12:30:00.000000Z"
    }
  }
}
This endpoint updates an existing subcategory with the provided information. All fields are optional and only provided fields will be updated.

Authentication

This endpoint does not require authentication.

Path Parameters

id
integer
required
The unique identifier of the subcategory to update

Request Body

name
string
Name of the subcategoryValidation:
  • Optional (only validated if provided)
  • Must be a string
  • Maximum length: 255 characters
description
string
Description of the subcategoryValidation:
  • Optional (nullable)
  • Must be a string
  • Maximum length: 1000 characters
category_id
integer
ID of the parent categoryValidation:
  • Optional (only validated if provided)
  • Must be a valid category ID that exists in the categories table

Response

success
boolean
Indicates if the request was successful
message
string
A success message confirming the update
data
object
curl --location --request PUT 'https://api.yourapp.com/subcategories/1' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "name": "Premium Smartphones",
  "description": "High-end mobile phones and accessories"
}'
{
  "success": true,
  "message": "Subcategory updated successfully",
  "data": {
    "subcategory": {
      "id": 1,
      "name": "Premium Smartphones",
      "description": "High-end mobile phones and accessories",
      "category": {
        "id": 1,
        "name": "Electronics",
        "description": "Electronic devices and components"
      },
      "created_at": "2024-03-08T09:15:00.000000Z",
      "updated_at": "2024-03-08T12:30:00.000000Z"
    }
  }
}

Build docs developers (and LLMs) love