API reference · Assets
POST/api/v1/assets/{id}/maintenance
Product availabilityAlgaPSA

Create asset maintenance schedule

Creates a maintenance schedule for the path asset ID in the authenticated tenant. The request body is validated with createMaintenanceScheduleSchema; schedule_type and frequency are required, while start_date is optional in the current shared date schema and the service falls back to now when absent. The service inserts asset_id from the path, tenant from context, timestamps, and a calculated next_maintenance value. It does not verify asset existence, 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.

RBAC · asset

Path parameters

idstring <uuid>Required
Asset UUID from assets.asset_id.

Request body

Content type: application/json · schema AssetMaintenanceScheduleCreateRequest

schedule_typestringRequired
Required type of maintenance schedule.
Enum: preventiveinspectioncalibrationreplacement
frequencystringRequired
Required recurrence frequency used to calculate next_maintenance.
Enum: dailyweeklymonthlyquarterlyyearlycustom
frequency_intervalnumber
Frequency multiplier. Defaults to service logic when absent.
≥ 1
start_datestring <date-time>
Schedule start date/time. The current schema makes this optional; the service falls back to now when absent.
end_datestring <date-time>
Optional schedule end date/time.
notesstring
Free-text schedule notes.
assigned_tostring <uuid>
Assigned user UUID from users.user_id.
is_activeboolean
Whether the schedule is active. Defaults to true in validation.
schedule_configobject
Custom scheduling configuration.

Response body

Success response 201 · schema AssetMaintenanceScheduleResponse

successbooleanRequired
Enum: true
dataobjectRequired
dataobject
schedule_idstring <uuid>Required
Primary key from asset_maintenance_schedules.schedule_id.
asset_idstring <uuid>Required
Asset UUID from asset_maintenance_schedules.asset_id.
schedule_typestring
Maintenance schedule type as used by ApiAssetController.
frequencystring
Recurrence frequency.
frequency_intervalnumberNullable
Frequency multiplier.
start_datestringNullable
Schedule start date/time.
end_datestringNullable
Schedule end date/time.
last_maintenancestringNullable
Last recorded maintenance date/time.
next_maintenancestringNullable
Next calculated maintenance date/time.
notesstringNullable
Free-text schedule notes.
assigned_tostring <uuid>Nullable
Assigned user UUID.
is_activeboolean
Whether the schedule is active.
schedule_configobjectNullable
Custom scheduling configuration.
created_atstring <date-time>
Creation timestamp.
updated_atstring <date-time>
Last update timestamp.
tenantstring <uuid>Required
Tenant UUID scoped from the request context.
metaobjectRequired
timestampstring <date-time>Required
Response timestamp generated by createApiResponse/createErrorResponse.
versionstringRequired
API response version string.

Response codes

201
Maintenance schedule 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 create or update asset maintenance schedules 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.