{
 "openapi": "3.1.0",
 "info": {
  "title": "Maintenance Orders (Manufacturing)",
  "version": "20261030b",
  "description": "Preventive and breakdown work in one document, deliberately: the ratio between them is the most useful number in maintenance, and it cannot be computed across two tables."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "maintenance-orders": {
    "type": "object",
    "required": [
     "title"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "Id",
      "readOnly": true
     },
     "org_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org id",
      "readOnly": true
     },
     "org_unit_id": {
      "type": "string",
      "format": "uuid",
      "description": "Org unit id",
      "readOnly": true
     },
     "order_no": {
      "type": "string",
      "description": "Order no",
      "readOnly": true
     },
     "title": {
      "type": "string",
      "description": "Title"
     },
     "description": {
      "type": "string",
      "description": "Description"
     },
     "equipment_id": {
      "type": "string",
      "format": "uuid",
      "description": "Machine"
     },
     "work_center_id": {
      "type": "string",
      "format": "uuid",
      "description": "Work center"
     },
     "location_id": {
      "type": "string",
      "format": "uuid",
      "description": "Location"
     },
     "plan_id": {
      "type": "string",
      "format": "uuid",
      "description": "From plan"
     },
     "order_type": {
      "type": "string",
      "description": "Type",
      "enum": [
       "corrective",
       "preventive",
       "predictive",
       "breakdown",
       "inspection",
       "calibration",
       "improvement",
       "statutory",
       "safety"
      ]
     },
     "priority": {
      "type": "string",
      "description": "Priority",
      "enum": [
       "emergency",
       "high",
       "medium",
       "low",
       "shutdown_only"
      ]
     },
     "failure_mode_id": {
      "type": "string",
      "format": "uuid",
      "description": "Failure mode"
     },
     "reason_id": {
      "type": "string",
      "format": "uuid",
      "description": "Reason id"
     },
     "downtime_event_id": {
      "type": "string",
      "format": "uuid",
      "description": "Downtime event id",
      "readOnly": true
     },
     "iot_alert_id": {
      "type": "string",
      "format": "uuid",
      "description": "Iot alert id",
      "readOnly": true
     },
     "nonconformance_id": {
      "type": "string",
      "format": "uuid",
      "description": "Nonconformance id",
      "readOnly": true
     },
     "requested_by": {
      "type": "string",
      "format": "uuid",
      "description": "Requested by",
      "readOnly": true
     },
     "reported_at": {
      "type": "string",
      "format": "date-time",
      "description": "Reported at",
      "readOnly": true
     },
     "required_by": {
      "type": "string",
      "format": "date",
      "description": "Required by"
     },
     "scheduled_start": {
      "type": "string",
      "format": "date-time",
      "description": "Scheduled start"
     },
     "scheduled_end": {
      "type": "string",
      "format": "date-time",
      "description": "Scheduled end"
     },
     "actual_start": {
      "type": "string",
      "format": "date-time",
      "description": "Actual start",
      "readOnly": true
     },
     "actual_end": {
      "type": "string",
      "format": "date-time",
      "description": "Actual end",
      "readOnly": true
     },
     "response_minutes": {
      "type": "string",
      "format": "decimal",
      "description": "Response minutes",
      "readOnly": true
     },
     "labor_minutes": {
      "type": "string",
      "format": "decimal",
      "description": "Labor minutes",
      "readOnly": true
     },
     "production_downtime_minutes": {
      "type": "string",
      "format": "decimal",
      "description": "Production downtime minutes",
      "readOnly": true
     },
     "assigned_to": {
      "type": "string",
      "format": "uuid",
      "description": "Assigned to"
     },
     "crew": {
      "type": "string",
      "description": "Crew"
     },
     "trade": {
      "type": "string",
      "description": "Trade"
     },
     "supplier_id": {
      "type": "string",
      "format": "uuid",
      "description": "Supplier"
     },
     "cost_labor": {
      "type": "string",
      "format": "decimal",
      "description": "Cost labor",
      "readOnly": true
     },
     "cost_parts": {
      "type": "string",
      "format": "decimal",
      "description": "Cost parts",
      "readOnly": true
     },
     "cost_contractor": {
      "type": "string",
      "format": "decimal",
      "description": "Cost contractor",
      "readOnly": true
     },
     "cost_total": {
      "type": "string",
      "format": "decimal",
      "description": "Cost total",
      "readOnly": true
     },
     "currency": {
      "type": "string",
      "description": "Currency",
      "readOnly": true
     },
     "cost_center_id": {
      "type": "string",
      "format": "uuid",
      "description": "Cost center"
     },
     "journal_id": {
      "type": "string",
      "format": "uuid",
      "description": "Journal id",
      "readOnly": true
     },
     "findings": {
      "type": "string",
      "description": "What was actually wrong"
     },
     "work_performed": {
      "type": "string",
      "description": "Work performed"
     },
     "root_cause": {
      "type": "string",
      "description": "Root cause"
     },
     "follow_up_required": {
      "type": "boolean",
      "description": "Follow up required",
      "readOnly": true
     },
     "follow_up_order_id": {
      "type": "string",
      "format": "uuid",
      "description": "Follow up order id",
      "readOnly": true
     },
     "status": {
      "type": "string",
      "description": "Status",
      "readOnly": true
     },
     "completed_by": {
      "type": "string",
      "format": "uuid",
      "description": "Completed by",
      "readOnly": true
     },
     "closed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Closed at",
      "readOnly": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Created at",
      "readOnly": true
     },
     "xf_text_1": {
      "type": "string",
      "description": "Xf text 1",
      "readOnly": true
     },
     "xf_text_2": {
      "type": "string",
      "description": "Xf text 2",
      "readOnly": true
     },
     "xf_text_3": {
      "type": "string",
      "description": "Xf text 3",
      "readOnly": true
     },
     "xf_text_4": {
      "type": "string",
      "description": "Xf text 4",
      "readOnly": true
     },
     "xf_text_5": {
      "type": "string",
      "description": "Xf text 5",
      "readOnly": true
     },
     "xf_num_1": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 1",
      "readOnly": true
     },
     "xf_num_2": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 2",
      "readOnly": true
     },
     "xf_num_3": {
      "type": "string",
      "format": "decimal",
      "description": "Xf num 3",
      "readOnly": true
     },
     "xf_date_1": {
      "type": "string",
      "format": "date",
      "description": "Xf date 1",
      "readOnly": true
     },
     "xf_date_2": {
      "type": "string",
      "format": "date",
      "description": "Xf date 2",
      "readOnly": true
     },
     "created_by": {
      "type": "string",
      "format": "uuid",
      "description": "Created by",
      "readOnly": true
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Updated at",
      "readOnly": true
     },
     "updated_by": {
      "type": "string",
      "format": "uuid",
      "description": "Updated by",
      "readOnly": true
     }
    }
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "paths": {
  "/api/mfg/maintenance-orders": {
   "get": {
    "summary": "list maintenance-orders",
    "operationId": "list_maintenance_orders_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create maintenance-orders",
    "operationId": "create_maintenance_orders_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{id}": {
   "get": {
    "summary": "get maintenance-orders",
    "operationId": "get_maintenance_orders_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change maintenance-orders",
    "operationId": "change_maintenance_orders_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete maintenance-orders",
    "operationId": "delete_maintenance_orders_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{parentId}/tasks": {
   "get": {
    "summary": "Tasks",
    "operationId": "action_maintenance_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Tasks",
    "operationId": "action_maintenance_orders_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{parentId}/tasks/{lineId}": {
   "put": {
    "summary": "Tasks",
    "operationId": "action_maintenance_orders_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Tasks",
    "operationId": "action_maintenance_orders_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{parentId}/parts": {
   "get": {
    "summary": "Parts",
    "operationId": "action_maintenance_orders_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "Parts",
    "operationId": "action_maintenance_orders_1_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{parentId}/parts/{lineId}": {
   "put": {
    "summary": "Parts",
    "operationId": "action_maintenance_orders_0_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "Parts",
    "operationId": "action_maintenance_orders_1_7",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_maintenance_orders_0_6",
    "description": "Body keys: overrides, preview, withLines",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{id}/start": {
   "post": {
    "summary": "Start",
    "operationId": "action_maintenance_orders_0_6",
    "description": "Body keys: startWithoutParts, assignedTo, stopMachine",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/mfg/maintenance-orders/{id}/complete": {
   "post": {
    "summary": "Complete",
    "operationId": "action_maintenance_orders_0_6",
    "description": "Body keys: findings*, laborMinutes, laborRate, contractorCost, workPerformed, rootCause, downtimeMinutes, followUpRequired",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}