API reference · AssetsPOST /api/v1/assets/{id}/maintenance/record
Record asset maintenance Inserts an asset_maintenance_history row for the path asset ID in the authenticated tenant. The request body requires maintenance_type, performed_by, and performed_at; schedule_id, duration, cost, notes, parts, and structured maintenance_data are optional. If schedule_id is supplied and a matching tenant schedule exists, the service updates that schedule last_maintenance and next_maintenance. It does not verify asset existence or performed_by before insert, does not set created_by, and publishes no event. In the current v1 asset route wiring, req.context may be absent because no route-level API-key auth wrapper sets it, causing a 500 before insert.
Path parameters id string <uuid> Required
Asset UUID from assets.asset_id.
Request body Content type: application/json · schema AssetRecordMaintenanceRequest
schedule_id string <uuid>
Optional maintenance schedule UUID. If present and found for the tenant, the schedule last_maintenance and next_maintenance are updated.
maintenance_type string Required
Required type of maintenance performed.
Enum: preventivecorrectiveinspectioncalibrationreplacement
performed_by string <uuid> Required
Required UUID of the user who performed maintenance. The service does not validate this user before insert.
performed_at string <date-time> Required
Required timestamp when maintenance was performed.
duration_hours number
Optional duration in hours.
≥ 0
cost number
Optional cost.
≥ 0
notes string
Optional notes.
parts_used array of string
Optional list of parts used.
maintenance_data object
Optional structured maintenance data.
Response body Success response 201 · schema AssetRecordMaintenanceResponse
success boolean Required
Enum: true
history_id string <uuid> Required
Primary key from asset_maintenance_history.history_id.
asset_id string <uuid> Required
Asset UUID from asset_maintenance_history.asset_id.
schedule_id string <uuid> Nullable
Optional related maintenance schedule UUID.
maintenance_type anyOf Required
Maintenance type recorded for the history row.
anyOf (option 1) string
Enum: preventivecorrectiveinspectioncalibrationreplacement
performed_by string <uuid> Required
User UUID supplied in the maintenance record.
performed_at string <date-time> Required
Timestamp when maintenance was performed.
duration_hours number Nullable
Maintenance duration in hours, when recorded.
cost number Nullable
Maintenance cost, when recorded.
notes string Nullable
Free-text notes.
parts_used array of string Nullable
Parts used, when recorded.
maintenance_data object Nullable
Arbitrary structured maintenance data.
description string Nullable
Description column when present in the maintenance history table.
created_at string <date-time> Required
History creation timestamp.
tenant string <uuid> Required
Tenant UUID scoped from the request context.
performed_by_user_name string Nullable
Concatenated user name from the joined users table.
timestamp string <date-time> Required
Response timestamp generated by createApiResponse/createErrorResponse.
version string Required
API response version string.
Response codes 201
Maintenance record created successfully.
400
Request body validation failed or the database rejected an invalid reference.
401
x-api-key is missing at middleware.
403
Authenticated request context lacks permission to update asset maintenance records when auth wiring is present.
409
Database unique constraint conflict if one is enforced.
500
Unexpected error, including missing req.context in the current route wiring.