Skip to main content

GET /api/categories/:id

Retrieve detailed information about a specific category by its UUID.

Authentication

This endpoint requires a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Path Parameters

id
string
required
UUID of the category to retrieve

Response

Returns the category object with all its properties.
id
string
Category UUID
name
string
Category name
type
string
Category type: INCOME, EXPENSE, or BOTH
isFixed
boolean
Whether this is a fixed expense/income
color
string
Hex color code for UI display
icon
string
Icon name (Font Awesome compatible)
parentId
string | null
Parent category UUID for hierarchical categories, or null for root categories
userId
string
UUID of the user who owns this category
createdAt
string
ISO 8601 timestamp of creation
updatedAt
string
ISO 8601 timestamp of last update
deletedAt
string | null
ISO 8601 timestamp of soft deletion, or null if active

Example Request

cURL
curl -X GET http://localhost:3000/api/categories/uuid-123 \
  -H "Authorization: Bearer <token>"
JavaScript
const categoryId = 'uuid-123';
const response = await fetch(`http://localhost:3000/api/categories/${categoryId}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`
  }
});

const category = await response.json();
Python
import requests

category_id = 'uuid-123'
headers = {'Authorization': f'Bearer {token}'}
response = requests.get(
    f'http://localhost:3000/api/categories/{category_id}',
    headers=headers
)

category = response.json()

Example Response

{
  "id": "uuid-123",
  "name": "Groceries",
  "type": "EXPENSE",
  "isFixed": false,
  "color": "#F59E0B",
  "icon": "shopping-cart",
  "parentId": "parent-uuid-456",
  "userId": "user-uuid",
  "createdAt": "2024-01-15T10:00:00.000Z",
  "updatedAt": "2024-01-15T10:00:00.000Z",
  "deletedAt": null
}

Error Responses

{
  "statusCode": 404,
  "message": "Category not found"
}
This error occurs when:
  • The category ID doesn’t exist
  • The category belongs to another user
  • The category has been soft-deleted
{
  "statusCode": 401,
  "message": "Unauthorized"
}
{
  "statusCode": 400,
  "message": "Validation failed (uuid is expected)"
}

Use Cases

Category Details

Display full category information in a detail view

Edit Form

Fetch category data to pre-populate an edit form

Validation

Verify category existence before creating transactions

Hierarchy Display

Show parent-child relationships in UI

List Categories

Get all categories with filtering

Update Category

Modify category properties

Delete Category

Soft delete a category

Build docs developers (and LLMs) love