Overview
The Maintenance API allows you to manage home maintenance tasks, including repairs, scheduled maintenance, and home improvements. Each item includes a title, category, and optional description.
Endpoints
Get All Maintenance Items
Retrieves all maintenance items for the authenticated user’s household, ordered by position.
Authentication : Required
Response
Array of maintenance item objects
Show Maintenance Item Fields
ID of the household this item belongs to
Title of the maintenance task
Maintenance category (e.g., “Plumbing”, “HVAC”, “Electrical”)
Optional detailed description
Position for ordering in the list
Whether the task is completed (default: false)
curl -X GET https://your-domain.com/api/maintenance \
-H "Authorization: Bearer YOUR_CLERK_TOKEN"
Example Response
[
{
"id" : "clx123abc" ,
"householdId" : "clx456def" ,
"title" : "Replace air filter" ,
"category" : "HVAC" ,
"description" : "Change filter in main unit" ,
"position" : 0 ,
"checked" : false ,
"createdAt" : "2024-03-15T10:00:00Z" ,
},
{
"id" : "clx789ghi" ,
"householdId" : "clx456def" ,
"title" : "Fix leaky faucet" ,
"category" : "Plumbing" ,
"description" : "Kitchen sink drips" ,
"position" : 1 ,
"checked" : false ,
"createdAt" : "2024-03-15T11:00:00Z" ,
}
]
Create or Reorder Maintenance Items
Creates a new maintenance item or reorders existing items.
Authentication : Required
Request Body (Create)
Request Body (Reorder)
Create Item
Reorder Items
Create Item
curl -X POST https://your-domain.com/api/maintenance \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Paint garage door",
"category": "Exterior",
"description": "Use weather-resistant paint"
}'
Response (Create)
{
"id" : "clxnew123" ,
"householdId" : "clx456def" ,
"title" : "Paint garage door" ,
"category" : "Exterior" ,
"description" : "Use weather-resistant paint" ,
"position" : 2 ,
"checked" : false ,
"createdAt" : "2024-03-15T12:00:00Z" ,
}
Response (Reorder)
Status: 200 OK
Update Maintenance Item
POST /api/maintenance/update
Updates an existing maintenance item’s details.
Authentication : Required
Request Body
curl -X POST https://your-domain.com/api/maintenance/update \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "clx123abc",
"title": "Replace HVAC filter",
"category": "HVAC",
"description": "Use MERV 11 filter"
}'
Response
Delete Maintenance Item
POST /api/maintenance/delete
Deletes (marks as completed) a maintenance item and creates a notification.
Authentication : Required
Request Body
curl -X POST https://your-domain.com/api/maintenance/delete \
-H "Authorization: Bearer YOUR_CLERK_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id": "clx123abc"}'
Response
{
"id" : "clx123abc" ,
"householdId" : "clx456def" ,
"title" : "Replace air filter" ,
"category" : "HVAC" ,
"description" : "Change filter in main unit" ,
"position" : 0 ,
"checked" : false ,
"createdAt" : "2024-03-15T10:00:00Z" ,
}
When a maintenance item is deleted, a notification is automatically created with:
Type : “maintenance”
Title : “Maintenance Completed”
Body : “Task completed: [title]“
Get Maintenance Count
GET /api/maintenance/count
Returns the total number of maintenance items for the household.
Authentication : Required
curl -X GET https://your-domain.com/api/maintenance/count \
-H "Authorization: Bearer YOUR_CLERK_TOKEN"
Response
Error Responses
User is not authenticated
or
500 Internal Server Error
Unexpected server error
Source Code Reference
Main routes: ~/workspace/source/src/app/api/maintenance/route.ts:19
Count endpoint: ~/workspace/source/src/app/api/maintenance/count/route.ts:19
Delete endpoint: ~/workspace/source/src/app/api/maintenance/delete/route.ts:20
Update endpoint: ~/workspace/source/src/app/api/maintenance/update/route.ts:19