Skip to content

M2 API Reference

The M2 Maintenance API provides endpoints for work orders, assets, vendors, and emergency management.

Production: https://m2.inspiringlivingsolutions.com/api
Development: http://localhost:3000/api

Requires Authentik SSO session via NextAuth.

GET /work-orders

Query Parameters:

ParameterTypeDescription
pagenumberPage number
limitnumberItems per page
statusstringFilter by status
prioritystringFilter by priority
villaIdstringFilter by property
assigneeIdstringFilter by assignee

Response:

{
"data": [
{
"id": "uuid",
"title": "AC not cooling",
"status": "IN_PROGRESS",
"priority": "HIGH",
"category": "HVAC",
"villa": { "id": "uuid", "name": "Villa Sunrise" },
"assignee": { "id": "uuid", "name": "John Tech" },
"createdAt": "2024-01-15T10:00:00Z"
}
],
"pagination": { "page": 1, "limit": 10, "total": 150 }
}
GET /work-orders/:id
POST /work-orders

Body:

{
"title": "AC not cooling",
"description": "Master bedroom AC not working",
"villaId": "uuid",
"category": "HVAC",
"priority": "HIGH",
"assetId": "uuid"
}
PATCH /work-orders/:id
POST /work-orders/:id/assign

Body:

{
"assigneeId": "uuid",
"assigneeType": "TECHNICIAN",
"dueDate": "2024-01-20T17:00:00Z"
}
POST /work-orders/:id/comments

Body:

{
"content": "Parts ordered, arriving tomorrow",
"type": "PUBLIC"
}

GET /assets
GET /assets/:id
POST /assets

Body:

{
"name": "Samsung AC Unit",
"category": "HVAC",
"villaId": "uuid",
"brand": "Samsung",
"model": "AR24TXHQ",
"serialNumber": "SN12345",
"purchaseDate": "2023-01-15",
"warrantyEndDate": "2026-01-15"
}
PATCH /assets/:id/health

Body:

{
"healthScore": 75,
"condition": "GOOD",
"notes": "Minor wear observed"
}

GET /vendors
GET /vendors/:id
POST /vendors

Body:

{
"companyName": "AC Service Co",
"contactName": "Somchai",
"email": "[email protected]",
"phone": "+66812345678",
"categories": ["HVAC", "ELECTRICAL"]
}
POST /vendors/:id/ratings

Body:

{
"workOrderId": "uuid",
"quality": 5,
"timeliness": 4,
"communication": 5,
"value": 4,
"comments": "Excellent service"
}

POST /emergencies

Body:

{
"villaId": "uuid",
"category": "WATER",
"severity": "CRITICAL",
"description": "Major water leak in kitchen",
"location": "Kitchen"
}
PATCH /emergencies/:id/status

Body:

{
"status": "CONTAINED",
"notes": "Water shut off, waiting for plumber"
}
POST /emergencies/:id/actions

Body:

{
"action": "Shut off main water valve",
"performedBy": "uuid"
}

GET /pmp/templates
POST /pmp/schedules

Body:

{
"templateId": "uuid",
"assetId": "uuid",
"frequency": "MONTHLY",
"startDate": "2024-01-01",
"assigneeId": "uuid"
}

POST /field-notes

Body (multipart/form-data):

  • content: Note text
  • type: TEXT | VOICE | PHOTO
  • workOrderId: Linked work order (optional)
  • assetId: Linked asset (optional)
  • file: Media file (for VOICE/PHOTO)

POST /timesheets

Body:

{
"workOrderId": "uuid",
"hours": 2.5,
"activityType": "REPAIR",
"date": "2024-01-15",
"notes": "Replaced compressor"
}

{
"error": {
"code": "WORK_ORDER_NOT_FOUND",
"message": "Work order not found",
"statusCode": 404
}
}