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

# Update Session

> Update a routing session. Today only its owning company can be changed.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, or you cannot manage the session's company or the new `company_slug`
- **404**: No session with this slug
- **422**: Invalid request body

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



## OpenAPI

````yaml /api-reference/openapi.json put /operations/sessions/{slug}
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://stage-api.getswitch.io
    description: Stage
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/sessions/{slug}:
    put:
      tags:
        - Routing Sessions
      summary: Update Session
      description: >-
        Update a routing session. Today only its owning company can be changed.


        **Failure Modes:**

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

        - **403**: Insufficient permissions, or you cannot manage the session's
        company or the new `company_slug`

        - **404**: No session with this slug

        - **422**: Invalid request body


        **Required Auth Scopes:**

        - `routing-sessions:manage`
      operationId: update_session
      parameters:
        - name: slug
          in: path
          required: true
          schema:
            type: string
            description: Session identifier, as sent when it was dispatched.
            title: Slug
          description: Session identifier, as sent when it was dispatched.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionUpdate'
      responses:
        '200':
          description: Session updated. Returns the updated session.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/pulse__core_api_lib__operations__sessions__schemas__SessionPublic
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Insufficient permissions.
        '404':
          description: Not Found. No session with this slug.
        '422':
          description: Unprocessable Entity. Validation failed.
        '500':
          description: Internal Server Error.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    SessionUpdate:
      properties:
        company_slug:
          type:
            - string
            - 'null'
          title: Company Slug
          description: Move the session to another company you can manage.
      type: object
      title: SessionUpdate
      description: Partial update for a session. Only sent fields are applied.
      examples:
        - company_slug: acme-mobility::milan
    pulse__core_api_lib__operations__sessions__schemas__SessionPublic:
      properties:
        slug:
          type: string
          title: Slug
          description: Session identifier.
        company_slug:
          type: string
          title: Company Slug
          description: Owning company.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: When the session was dispatched.
        updated_at:
          type:
            - string
            - 'null'
          format: date-time
          title: Updated At
          description: Last update, if any.
        routes:
          items:
            $ref: '#/components/schemas/RoutePublic'
          type: array
          title: Routes
          description: Routes with their drivers and operations.
          default: []
      type: object
      required:
        - slug
        - company_slug
        - created_at
      title: SessionPublic
      description: Full session detail response (includes routes + operations).
      examples:
        - company_slug: acme-mobility
          created_at: '2026-11-30T07:58:10Z'
          routes:
            - 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
              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'
              start_at: '2026-11-30T08:00:00Z'
              total_distance: 14.2
          slug: 3f6c2a9e-8d41-4b7a-9c2e-5a1f0e7d9b13
    RoutePublic:
      properties:
        id:
          type: integer
          title: Id
          description: Route ID, used in the `/operations/routes` URLs.
        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.
        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
        - route_identifier
        - reroute_enabled
        - routing_parameters
        - operations_parameters
      title: RoutePublic
      description: Route as returned in session detail responses.
    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.