---
updatedAt: 2026-09-23T20:14:53.000Z
agentTools:
  projectIndex: https://mediroutes-api.readme.io/llms.txt
---

# Shop Trip

Runs the scheduling algorithm for one trip and returns ranked recommendations for which route (run) it should be scheduled on.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "V1",
    "title": "MediroutesAPI V1"
  },
  "paths": {
    "/api/v{version}/route/shopTrip": {
      "get": {
        "tags": [
          "Route"
        ],
        "summary": "Shop Trip",
        "description": "Runs the scheduling algorithm for one trip and returns ranked recommendations for which route (run) it should be scheduled on.",
        "operationId": "shop-trip",
        "parameters": [
          {
            "name": "api_key",
            "in": "query",
            "description": "",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "service_id",
            "in": "query",
            "description": "Service id of the trip's pickup or dropoff event.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "The date the trip should be scheduled on (must match the trip's service date).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "description": "access token",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Run recommendations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RunRecommendationModel"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RunRecommendationModel"
                  }
                }
              },
              "application/xml": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RunRecommendationModel"
                  }
                }
              },
              "text/xml": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RunRecommendationModel"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or unaligned data. Error message will be returned with response."
          },
          "403": {
            "description": "The api key used does not have access to this resource."
          },
          "404": {
            "description": "No trip exists for the given service id."
          }
        },
        "x-ai-description": "Shops a trip: runs the scheduling algorithm against every eligible route on the given date and returns ranked recommendations (best first) for which route the trip should go on. Identify the trip by the service id of either of its events; date is the day being scheduled (typically a future day) and must match the trip's service date.",
        "x-ai-when-to-use": "The user asks where a trip should be scheduled, which route/run best fits a trip, or to schedule a trip without naming a route. Review the recommendations, then place the trip with PUT route/saveRoute (pass the same date as route_date).",
        "x-ai-side-effects": "read-only",
        "x-ai-returns": "Array of run recommendations with rank, route_id, route_name, driver/vehicle names, distance metrics, insertion indexes, and any constraint violations. Empty when no eligible route exists.",
        "x-ai-required-permission": "dispatch",
        "x-ai-display": {
          "title": "Route recommendations for {date}",
          "key": "route_id",
          "columns": [
            {
              "field": "rank",
              "header": "Rank"
            },
            {
              "field": "route_name",
              "header": "Route"
            },
            {
              "field": "driver_name",
              "header": "Driver"
            },
            {
              "field": "vehicle_name",
              "header": "Vehicle"
            },
            {
              "field": "distance_to_pickup_miles",
              "header": "Miles to Pickup"
            },
            {
              "field": "added_distance_miles",
              "header": "Added Miles"
            },
            {
              "field": "has_violations",
              "header": "Has Violations"
            }
          ],
          "actions": [
            {
              "label": "Schedule on this route",
              "operation": "save-route",
              "args": "body.route_id={route_id};body.route_date={call.date};body.service_ids=[{call.service_id}]"
            }
          ]
        },
        "x-ai-inputs": [
          {
            "name": "date",
            "label": "Trip Date",
            "control": "date"
          },
          {
            "name": "service_id",
            "label": "Trip",
            "control": "select",
            "options": {
              "operation": "get-ridesfordate",
              "valueField": "pickup.service_id",
              "labelTemplate": "{rider.last_name}, {rider.first_name} — {pickup.pickup_time} ({status})",
              "args": "date={date};includeUnScheduled=true"
            }
          }
        ]
      }
    }
  },
  "servers": [
    {
      "url": "https://api.mediroutes.com"
    }
  ],
  "components": {
    "schemas": {
      "RunRecommendationModel": {
        "description": "Ticket 12660 - One candidate route (run) a trip could be scheduled onto, produced by the\r\nscheduling algorithm when \"shopping\" a trip. Ordered best-first (least added deadhead).",
        "type": "object",
        "properties": {
          "rank": {
            "format": "int32",
            "type": "integer"
          },
          "route_id": {
            "format": "int32",
            "type": "integer"
          },
          "route_name": {
            "type": "string"
          },
          "driver_name": {
            "type": "string"
          },
          "vehicle_name": {
            "type": "string"
          },
          "distance_to_pickup_miles": {
            "format": "double",
            "type": "number"
          },
          "added_distance_miles": {
            "format": "double",
            "type": "number"
          },
          "total_distance_after_miles": {
            "format": "double",
            "type": "number"
          },
          "pickup_insert_index": {
            "format": "int32",
            "type": "integer"
          },
          "dropoff_insert_index": {
            "format": "int32",
            "type": "integer"
          },
          "has_violations": {
            "type": "boolean"
          },
          "violations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```