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"
}
Field Type Required Default Description
name string Yes - Category name (unique)
color string No #6366f1 Hex color code
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Electronics",
"color": "#3b82f6"
}
Code Message
400 Category already exists
400 Invalid 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)
Color Hex Use Case
Blue #3b82f6 Electronics, Technology
Green #22c55e Tools, Outdoor
Purple #a855f7 Media, Entertainment
Orange #f97316 Kitchen, Home
Red #ef4444 Important, Priority
Indigo #6366f1 Default