Skip to main content
ADMIN ACCESS REQUIRED - This endpoint requires authentication with an ADMIN role.

Overview

Updates an existing category’s information. The category is identified by its name in the URL path.

Authentication

This endpoint requires:
  • Valid JWT token in the Authorization header
  • User must have ADMIN role

Request

name
string
required
The current name of the category to update. This is used as the route parameter.

Request Body

name
string
required
The new name for the category.
  • Required: Yes
  • Type: String
  • Max Length: 255 characters
description
string
The new description for the category.
  • Required: No
  • Type: String
  • Max Length: 255 characters

Validation Rules

  • name: Required, string, maximum 255 characters
  • description: Optional (nullable), string, maximum 255 characters

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success message indicating the category was updated
data
object
required
category
object
required
The updated category object
id
integer
required
Unique identifier for the category
name
string
required
Updated category name (max 255 characters)
description
string
Updated category description (max 255 characters)
created_at
string
required
Timestamp when the category was created
updated_at
string
required
Timestamp when the category was last updated (reflects current update)
deleted_at
string
Timestamp when the category was soft deleted (null if active)

Code Examples

curl -X PUT "https://api.example.com/category/Hardware" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Accept-Language: en" \
  -d '{
    "name": "Hardware Support",
    "description": "Updated description for hardware issues and repairs"
  }'

Response Examples

Success Response (200 OK)

{
  "success": true,
  "message": "Category updated successfully",
  "data": {
    "category": {
      "id": 1,
      "name": "Hardware Support",
      "description": "Updated description for hardware issues and repairs",
      "created_at": "2026-03-08T10:30:00.000000Z",
      "updated_at": "2026-03-08T14:20:00.000000Z",
      "deleted_at": null
    }
  }
}

Validation Error Response (422 Unprocessable Entity)

Returned when validation fails:
{
  "success": false,
  "message": "The given data was invalid.",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}

Not Found Response (404 Not Found)

Returned when the category with the specified name does not exist:
{
  "success": false,
  "message": "Category not found"
}

Unauthorized Response (401 Unauthorized)

{
  "success": false,
  "message": "Unauthenticated"
}

Forbidden Response (403 Forbidden)

Returned when the authenticated user does not have ADMIN role:
{
  "success": false,
  "message": "Unauthorized. Admin access required."
}

Error Codes

Status CodeDescription
200Success - Category updated
401Unauthorized - Invalid or missing JWT token
403Forbidden - User does not have ADMIN role
404Not Found - Category does not exist
422Validation Error - Invalid input data
500Internal Server Error

Notes

  • The category is identified by its name in the URL path
  • The request body can include a new name to rename the category
  • Both name and description fields are validated on update
  • The updated_at timestamp will be automatically updated to reflect the current time

Build docs developers (and LLMs) love