Skip to main content
PUT
/
api
/
management
/
categories
/
{id}
Update Category
curl --request PUT \
  --url https://api.example.com/api/management/categories/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
{
  "success": true,
  "timestamp": "<string>",
  "data": {
    "id": 123,
    "name": "<string>"
  },
  "message": "<string>",
  "error": {}
}

Endpoint

PUT /api/management/categories/{id}

Authentication

Required: ADMIN role This endpoint requires authentication with an admin user account. Include a valid JWT token in the Authorization header.

Request Headers

Authorization: Bearer <token>
Content-Type: application/json

Path Parameters

id
long
required
The unique identifier of the category to update

Request Body

name
string
required
Updated name of the categoryValidation:
  • Cannot be blank
  • Must be between 2 and 100 characters

Response

success
boolean
required
Indicates if the request was successful
timestamp
string
required
ISO 8601 timestamp of the response
data
object
required
The updated category object
id
long
required
Unique identifier for the category
name
string
required
Updated name of the category
message
string
Optional message
error
object
Error details (null on success)

Example Request

curl -X PUT "http://localhost:8080/api/management/categories/1" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Literary Fiction"
  }'

Example Response

Success (200 OK)

{
  "success": true,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": {
    "id": 1,
    "name": "Literary Fiction"
  },
  "message": null,
  "error": null
}

Error - Category Not Found (404)

{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": null,
  "message": null,
  "error": {
    "message": "Category not found with id: 999",
    "details": []
  }
}

Error - Validation Failed (400)

{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": null,
  "message": null,
  "error": {
    "message": "Validation failed",
    "details": [
      "Category name cannot be blank"
    ]
  }
}

Error - Unauthorized (401)

{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": null,
  "message": null,
  "error": {
    "message": "Unauthorized",
    "details": []
  }
}

Error - Forbidden (403)

{
  "success": false,
  "timestamp": "2026-03-03T10:30:00Z",
  "data": null,
  "message": null,
  "error": {
    "message": "Access denied. ADMIN role required.",
    "details": []
  }
}

Validation Rules

The category name must satisfy the following constraints:
  • Not blank: The name field is required and cannot be empty or contain only whitespace
  • Length: Must be between 2 and 100 characters (inclusive)

Source Code Reference

Controller: apps/spring-boot-app/src/main/java/me/seyrek/library_management_system/category/controller/CategoryManagementController.java:29 DTO: apps/spring-boot-app/src/main/java/me/seyrek/library_management_system/category/dto/CategoryUpdateRequest.java:6

Build docs developers (and LLMs) love