Skip to main content

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

GET /api/maintenance
endpoint
Retrieves all maintenance items for the authenticated user’s household, ordered by position.
Authentication: Required Response
items
array
Array of maintenance item objects
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

POST /api/maintenance
endpoint
Creates a new maintenance item or reorders existing items.
Authentication: Required Request Body (Create) Request Body (Reorder)
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)
Positions updated
Status: 200 OK

Update Maintenance Item

POST /api/maintenance/update
endpoint
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
{
  "count": 1
}

Delete Maintenance Item

POST /api/maintenance/delete
endpoint
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
endpoint
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
{
  "count": 4
}

Error Responses

401 Unauthorized
User is not authenticated
Unauthorized
400 Bad Request
Missing required fields
Missing fields
or
Missing ID
500 Internal Server Error
Unexpected server error
Internal 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

Build docs developers (and LLMs) love