> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getswitch.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Route

> Update a route's `reroute_enabled`, `routing_parameters` or `operations_parameters`. Only the fields you send change; the two parameter objects are replaced as a whole and cannot be null.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, or you cannot manage the route's company
- **404**: No route with this ID
- **422**: Invalid request body, e.g. a parameter object set to null

**Required Auth Scopes:**
- `routing-operations:manage`



## OpenAPI

````yaml /api-reference/openapi.json put /operations/routes/{route_id}
openapi: 3.1.0
info:
  title: SWITCH API
  version: '1.0'
  description: >-
    The SWITCH API gives mobility and logistics teams programmatic access to
    SWITCH forecasts, fleet operations, routing and analytics. Every request is
    authenticated with an API key sent as a bearer token.
servers:
  - url: https://api.getswitch.io
    description: Production
security: []
tags:
  - name: Forecast
    description: Demand forecasts per zone and time window.
  - name: Operations
    description: Fleet imbalance, rebalancing suggestions and generated tasks.
  - name: Routing
    description: Route optimisation for single and multiple fleets.
  - name: Routing Sessions
    description: Saved routing sessions, their routes and drivers.
  - name: Routing Operations
    description: Complete, undo and re-route the stops of a route.
  - name: Fleet Management
    description: Your depots, stations, drivers and cargo vehicles.
  - name: Integrations
    description: Vehicles, statuses and commands on your fleet platform.
  - name: Station Based Analytics
    description: Analytics for station-based (docked) services.
  - name: Zone Based Analytics
    description: Analytics for free-floating services, by zone.
  - name: Free Float Analytics
    description: Trip history for free-floating services.
  - name: Transit Analytics
    description: Punctuality and service delivery for public transit.
  - name: Live
    description: Real-time fleet, delivery and transit status.
  - name: Grids
    description: Spatial grids used by forecasts and analytics.
  - name: API Keys
    description: Create and manage the API keys you call this API with.
paths:
  /operations/routes/{route_id}:
    put:
      tags:
        - Routing Sessions
      summary: Update Route
      description: >-
        Update a route's `reroute_enabled`, `routing_parameters` or
        `operations_parameters`. Only the fields you send change; the two
        parameter objects are replaced as a whole and cannot be null.


        **Failure Modes:**

        - **401**: Token is missing or invalid

        - **403**: Insufficient permissions, or you cannot manage the route's
        company

        - **404**: No route with this ID

        - **422**: Invalid request body, e.g. a parameter object set to null


        **Required Auth Scopes:**

        - `routing-operations:manage`
      operationId: update_route
      parameters:
        - name: route_id
          in: path
          required: true
          schema:
            type: integer
            description: Route ID, from the session detail or the route list.
            title: Route Id
          description: Route ID, from the session detail or the route list.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RouteUpdate'
      responses:
        '200':
          description: Route updated. Returns the updated route detail.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RouteDetailPublic'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Insufficient permissions.
        '404':
          description: Not Found. No route with this ID.
        '422':
          description: Unprocessable Entity. Validation failed.
        '500':
          description: Internal Server Error.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    RouteUpdate:
      properties:
        reroute_enabled:
          type:
            - boolean
            - 'null'
          title: Reroute Enabled
          description: Allow or stop re-optimizing this route while it runs.
        operations_parameters:
          additionalProperties: true
          type:
            - object
            - 'null'
          title: Operations Parameters
          description: New free-form route data; replaces the whole object. Not null.
        routing_parameters:
          additionalProperties: true
          type:
            - object
            - 'null'
          title: Routing Parameters
          description: >-
            New vehicle and shift parameters used when rerouting (see Dispatch
            Session); replaces the whole object. Not null.
      type: object
      title: RouteUpdate
      description: Partial update for a route. Only the three mutable fields are exposed.
      examples:
        - reroute_enabled: true
          routing_parameters:
            end_coords:
              latitude: 45.4887
              longitude: 9.2415
            max_capacities:
              charged_battery: 40
              empty_battery: 40
              vehicles: 12
            max_duration: 150
            start_capacities:
              charged_battery: 40
              empty_battery: 0
              vehicles: 0
            start_coords:
              latitude: 45.4887
              longitude: 9.2415
            start_time: '2026-11-30T08:00:00Z'
    RouteDetailPublic:
      properties:
        id:
          type: integer
          title: Id
          description: Route ID.
        session_slug:
          type: string
          title: Session Slug
          description: Session the route belongs to.
        route_identifier:
          type: string
          title: Route Identifier
          description: Your name for the route.
        reroute_enabled:
          type: boolean
          title: Reroute Enabled
          description: Whether the route can be re-optimized while it runs.
        routing_parameters:
          additionalProperties: true
          type: object
          title: Routing Parameters
          description: Vehicle and shift parameters used when rerouting.
        operations_parameters:
          additionalProperties: true
          type: object
          title: Operations Parameters
          description: Free-form data stored with the route.
        start_at:
          type:
            - string
            - 'null'
          format: date-time
          title: Start At
          description: Planned start.
        end_at:
          type:
            - string
            - 'null'
          format: date-time
          title: End At
          description: Planned end.
        total_distance:
          type:
            - number
            - 'null'
          title: Total Distance
          description: Total planned distance in kilometres.
        status:
          $ref: '#/components/schemas/RouteStatus'
          description: >-
            `completed` when no operation is left open. Otherwise `expired` when
            the route's last estimated arrival is older than the expiration
            window (24 hours by default), `late` when an open operation is past
            its estimated arrival, and `active` otherwise.
        total_operations:
          type: integer
          title: Total Operations
          description: Number of operations.
        completed_operations:
          type: integer
          title: Completed Operations
          description: Completed operations.
        progress:
          type: number
          title: Progress
          description: 'Completion ratio: completed/total (0.0–1.0).'
        drivers:
          items:
            $ref: '#/components/schemas/RouteDriverPublic'
          type: array
          title: Drivers
          description: Assigned drivers.
          default: []
        operations:
          items:
            $ref: '#/components/schemas/OperationPublic'
          type: array
          title: Operations
          description: Operations, ordered by step.
          default: []
      type: object
      required:
        - id
        - session_slug
        - route_identifier
        - reroute_enabled
        - routing_parameters
        - operations_parameters
        - status
        - total_operations
        - completed_operations
        - progress
      title: RouteDetailPublic
      description: Full route detail response (includes operations + drivers).
      examples:
        - completed_operations: 1
          drivers:
            - email: marco.bianchi@acme-mobility.com
              full_name: Marco Bianchi
              id: 57
          end_at: '2026-11-30T09:40:00Z'
          id: 412
          operations:
            - additional_notes: Battery level (12.0%) below threshold (20.0%)
              address: Via Torino 2, 20123 Milano MI
              completed_at: '2026-11-30T08:17:42Z'
              estimated_arrive: '2026-11-30T08:14:00Z'
              id: 9031
              latitude: 45.4642
              longitude: 9.1856
              provider: acme-mobility
              routing_parameters:
                capacity_delta:
                  charged_battery: -1
                  empty_battery: 1
                profit: 2.4
              step: 1
              task_type: battery_swap
              vehicle_properties:
                battery_level: 12
                id: acme-sc-0193
                last_moved: '2026-11-30T06:41:03Z'
                last_seen: '2026-11-30T07:50:12Z'
                lat: 45.4642
                licence_plate: SC0193
                lon: 9.1856
                status: available
                vehicle_model: S-200
                vehicle_type: scooter
            - additional_notes: 'Zone surplus 1.0 vehicles (threshold: 1.5)'
              address: Via Mazzini 9, 20123 Milano MI
              estimated_arrive: '2026-11-30T08:23:00Z'
              id: 9032
              latitude: 45.4671
              longitude: 9.1883
              provider: acme-mobility
              routing_parameters:
                capacity_delta:
                  vehicles: 1
                profit: 2.1
              step: 2
              task_type: pickup
          operations_parameters:
            strategies:
              - slug: battery-threshold
                strat_params:
                  threshold: 20
          progress: 0.5
          reroute_enabled: true
          route_identifier: R1
          routing_parameters:
            end_coords:
              latitude: 45.4887
              longitude: 9.2415
            max_capacities:
              charged_battery: 40
              empty_battery: 40
              vehicles: 12
            max_duration: 120
            start_capacities:
              charged_battery: 40
              empty_battery: 0
              vehicles: 0
            start_coords:
              latitude: 45.4887
              longitude: 9.2415
            start_time: '2026-11-30T08:00:00Z'
          session_slug: 3f6c2a9e-8d41-4b7a-9c2e-5a1f0e7d9b13
          start_at: '2026-11-30T08:00:00Z'
          status: active
          total_distance: 14.2
          total_operations: 2
    RouteStatus:
      type: string
      enum:
        - active
        - late
        - expired
        - completed
      title: RouteStatus
      description: |-
        Computed route status based on operation state and timing.

        Assigned per-route in list responses. Display priority is
        ``completed > late > active > expired``.
    RouteDriverPublic:
      properties:
        id:
          type: integer
          title: Id
          description: User ID of the driver.
        full_name:
          type: string
          title: Full Name
          description: Driver's full name.
        email:
          type: string
          title: Email
          description: Driver's email.
      type: object
      required:
        - id
        - full_name
        - email
      title: RouteDriverPublic
      description: Driver assigned to a route.
      examples:
        - email: marco.bianchi@acme-mobility.com
          full_name: Marco Bianchi
          id: 57
    OperationPublic:
      properties:
        id:
          type: integer
          title: Id
          description: Operation ID.
        step:
          type: integer
          title: Step
          description: Position of the operation in the route.
        task_type:
          type: string
          title: Task Type
          description: What the operator does at the stop, e.g. `pickup`.
        latitude:
          type: number
          title: Latitude
          description: Latitude of the stop (WGS84).
        longitude:
          type: number
          title: Longitude
          description: Longitude of the stop (WGS84).
        provider:
          type: string
          title: Provider
          description: Fleet the vehicle belongs to.
        address:
          type:
            - string
            - 'null'
          title: Address
          description: Street address, if known.
        vehicle_properties:
          $ref: '#/components/schemas/VehicleWithoutZone'
          description: Snapshot of the vehicle at planning time.
        estimated_arrive:
          type: string
          format: date-time
          title: Estimated Arrive
          description: Estimated arrival time.
        routing_parameters:
          additionalProperties: true
          type: object
          title: Routing Parameters
          description: Free-form data of the stop, as dispatched.
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
          title: Completed At
          description: When the operation was completed; absent while open.
        cancelled:
          type:
            - string
            - 'null'
          title: Cancelled
          description: Cancellation reason; absent unless cancelled.
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Free-text notes.
      type: object
      required:
        - id
        - step
        - task_type
        - latitude
        - longitude
        - provider
        - estimated_arrive
        - routing_parameters
      title: OperationPublic
      description: Operation as returned in session detail responses.
      examples:
        - additional_notes: Battery level (12.0%) below threshold (20.0%)
          address: Via Torino 2, 20123 Milano MI
          completed_at: '2026-11-30T08:17:42Z'
          estimated_arrive: '2026-11-30T08:14:00Z'
          id: 9031
          latitude: 45.4642
          longitude: 9.1856
          provider: acme-mobility
          routing_parameters:
            capacity_delta:
              charged_battery: -1
              empty_battery: 1
            profit: 2.4
          step: 1
          task_type: battery_swap
          vehicle_properties:
            battery_level: 12
            id: acme-sc-0193
            last_moved: '2026-11-30T06:41:03Z'
            last_seen: '2026-11-30T07:50:12Z'
            lat: 45.4642
            licence_plate: SC0193
            lon: 9.1856
            status: available
            vehicle_model: S-200
            vehicle_type: scooter
    VehicleWithoutZone:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier for the vehicle
        licence_plate:
          type:
            - string
            - 'null'
          title: Licence Plate
          description: Licence plate number of the vehicle
        lat:
          type:
            - number
            - 'null'
          title: Lat
          description: Latitude of the vehicle's current location
        lon:
          type:
            - number
            - 'null'
          title: Lon
          description: Longitude of the vehicle's current location
        vehicle_type:
          type:
            - string
            - 'null'
          title: Vehicle Type
          description: Type of the vehicle, e.g., 'scooter', 'bike', 'car'
        vehicle_model:
          type:
            - string
            - 'null'
          title: Vehicle Model
          description: Model of the vehicle, e.g., 'Model X', 'Model Y'
        battery_level:
          type:
            - integer
            - 'null'
          title: Battery Level
          description: Battery level of the vehicle, e.g., 100 for 100%
        battery_level_master:
          type:
            - integer
            - 'null'
          title: Battery Level Master
          description: >-
            Master battery level percentage (custom MDS setup only). None when
            not reported by the provider.
        last_seen:
          type:
            - string
            - 'null'
          format: date-time
          title: Last Seen
          description: Timestamp of the last time the vehicle was seen in the system
        last_moved:
          type:
            - string
            - 'null'
          format: date-time
          title: Last Moved
          description: Timestamp of the last time the vehicle moved
        status:
          type:
            - string
            - 'null'
          title: Status
          description: Current status of the vehicle, e.g., 'available', 'in-use'
      type: object
      required:
        - id
        - battery_level
      title: VehicleWithoutZone
      description: >-
        Represents a vehicle without zone assignment.


        Base schema containing all vehicle attributes except zone_id.

        Used when a grid service is not available and spatial zone mapping is
        skipped.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. Create one in the
        SWITCH Copilot under **Settings → API keys** (needs the API keys
        permission in your company), or with `POST /auth/api-keys`. The key is
        shown once, at creation.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.