Skip to content

Categories API

Manage item categories.

Get all categories with item counts.

GET /api/categories
{
"categories": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Electronics",
"color": "#3b82f6",
"_count": {
"items": 15
}
},
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "Tools",
"color": "#22c55e",
"_count": {
"items": 8
}
}
]
}

Add a new category.

POST /api/categories
{
"name": "Electronics",
"color": "#3b82f6"
}
FieldTypeRequiredDefaultDescription
namestringYes-Category name (unique)
colorstringNo#6366f1Hex color code
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Electronics",
"color": "#3b82f6"
}
CodeMessage
400Category already exists
400Invalid color format

Modify an existing category.

PUT /api/categories/[id]
{
"name": "Consumer Electronics",
"color": "#2563eb"
}

Returns the updated category.


Remove a category.

DELETE /api/categories/[id]
{
"success": true
}

Note: Items Not Deleted Deleting a category does not delete its items. Items will become uncategorized.


Colors must be valid hex color codes:

  • 6-digit: #3b82f6
  • 3-digit: #38f (expanded to #3388ff)
ColorHexUse Case
Blue#3b82f6Electronics, Technology
Green#22c55eTools, Outdoor
Purple#a855f7Media, Entertainment
Orange#f97316Kitchen, Home
Red#ef4444Important, Priority
Indigo#6366f1Default