Skip to main content
DELETE
/
api
/
categories
/
:categoryId
Delete Category
curl --request DELETE \
  --url https://api.example.com/api/categories/:categoryId \
  --header 'Authorization: <authorization>'
{
  "message": "Category deleted successfully"
}
Permanently deletes a category from the system. This endpoint requires admin authentication.
This endpoint requires admin privileges. You must include a valid JWT token with admin role in the Authorization header.
This operation is irreversible. Make sure you want to permanently delete the category before proceeding.

Request

Path Parameters

categoryId
string
required
The unique MongoDB ObjectId of the category to delete

Headers

Authorization
string
required
Bearer token with admin privilegesExample: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Response

message
string
Success message confirming the deletion
{
  "message": "Category deleted successfully"
}

Error Responses

error
string
Error message describing what went wrong

404 - Category Not Found

Returned when no category exists with the specified ID.
{
  "error": "Category not found"
}

401 - Unauthorized

Returned when the authentication token is missing or invalid.
{
  "error": "No token provided"
}

403 - Forbidden

Returned when the authenticated user is not an admin.
{
  "error": "Admin access required"
}

500 - Internal Server Error

{
  "error": "Database connection failed"
}

Example Request

curl -X DELETE https://api.vaniyk-empire.com/api/categories/507f1f77bcf86cd799439011 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Notes

  • The deletion is permanent and cannot be undone
  • The categoryId parameter must be a valid MongoDB ObjectId
  • Consider the impact on any content (articles, posts, etc.) that may be associated with this category before deletion

Build docs developers (and LLMs) love