{
 "openapi": "3.1.0",
 "info": {
  "title": "Routes (Supply Chain)",
  "version": "20261030b",
  "description": "The drawn line and the plan behind it. Sequencing the stops is nearest-neighbour with time windows pulling a stop forward: crude, fast, and typically within a fifth of optimal on a delivery round."
 },
 "servers": [
  {
   "url": "https://{tenant}.tranxact.ai",
   "variables": {
    "tenant": {
     "default": "demo"
    }
   }
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer"
   }
  },
  "schemas": {
   "transport-routes": {
    "type": "object",
    "required": [
     "name"
    ],
    "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
     },
     "route_no": {
      "type": "string",
      "description": "Route no",
      "readOnly": true
     },
     "name": {
      "type": "string",
      "description": "Name"
     },
     "route_type": {
      "type": "string",
      "description": "Type",
      "enum": [
       "delivery",
       "collection",
       "milk_run",
       "shuttle",
       "line_haul",
       "backhaul",
       "service"
      ]
     },
     "load_id": {
      "type": "string",
      "format": "uuid",
      "description": "Load"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid",
      "description": "Vehicle"
     },
     "driver_id": {
      "type": "string",
      "format": "uuid",
      "description": "Driver"
     },
     "is_recurring": {
      "type": "boolean",
      "description": "Runs again"
     },
     "recurrence": {
      "type": "string",
      "description": "How often"
     },
     "route_date": {
      "type": "string",
      "format": "date",
      "description": "Date"
     },
     "planned_start_at": {
      "type": "string",
      "format": "date-time",
      "description": "Planned start"
     },
     "planned_end_at": {
      "type": "string",
      "format": "date-time",
      "description": "Planned end"
     },
     "actual_start_at": {
      "type": "string",
      "format": "date-time",
      "description": "Actual start"
     },
     "actual_end_at": {
      "type": "string",
      "format": "date-time",
      "description": "Actual end"
     },
     "stop_count": {
      "type": "integer",
      "description": "Stop count",
      "readOnly": true
     },
     "distance_km": {
      "type": "string",
      "format": "decimal",
      "description": "Distance (km)"
     },
     "drive_minutes": {
      "type": "string",
      "format": "decimal",
      "description": "Driving minutes"
     },
     "service_minutes": {
      "type": "string",
      "format": "decimal",
      "description": "Minutes on site"
     },
     "polyline": {
      "type": "object",
      "description": "Polyline",
      "readOnly": true
     },
     "optimization": {
      "type": "string",
      "description": "Sequenced by",
      "enum": [
       "none",
       "shortest",
       "fastest",
       "least_cost",
       "balanced",
       "time_windows",
       "manual"
      ]
     },
     "planned_cost": {
      "type": "string",
      "format": "decimal",
      "description": "Planned cost"
     },
     "actual_cost": {
      "type": "string",
      "format": "decimal",
      "description": "Actual cost"
     },
     "currency": {
      "type": "string",
      "description": "Currency"
     },
     "co2_kg": {
      "type": "string",
      "format": "decimal",
      "description": "CO2 (kg)"
     },
     "status": {
      "type": "string",
      "description": "Status",
      "readOnly": true
     },
     "notes": {
      "type": "string",
      "description": "Notes"
     },
     "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/scm/transport-routes": {
   "get": {
    "summary": "list transport-routes",
    "operationId": "list_transport_routes_0_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "post": {
    "summary": "create transport-routes",
    "operationId": "create_transport_routes_1_4",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/scm/transport-routes/{id}": {
   "get": {
    "summary": "get transport-routes",
    "operationId": "get_transport_routes_0_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "put": {
    "summary": "change transport-routes",
    "operationId": "change_transport_routes_1_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   },
   "delete": {
    "summary": "delete transport-routes",
    "operationId": "delete_transport_routes_2_5",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  },
  "/api/scm/transport-routes/{id}/copy": {
   "post": {
    "summary": "Copy",
    "operationId": "action_transport_routes_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/scm/transport-routes/{id}/optimize": {
   "post": {
    "summary": "Optimize",
    "operationId": "action_transport_routes_0_6",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "No or bad credential"
     },
     "403": {
      "description": "Not granted"
     },
     "422": {
      "description": "Refused by validation"
     }
    }
   }
  }
 }
}