> ## 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.

# Dispatch Session

> Dispatch a routing session: its routes, their operations in order, and the drivers of each route, in one transaction. Typically the body is built from a routing plan (`POST /operations/routing` or `/operations/routing/multi-fleet`). Routes without operations are skipped. Drivers then see their routes in `GET /operations/routes`.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, `company_slug` is a company you cannot manage, or a driver is outside your company and its child companies
- **404**: A driver does not exist
- **409**: A session with this `slug` already exists
- **422**: Invalid request body

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



## OpenAPI

````yaml /api-reference/openapi.json post /operations/sessions
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/sessions:
    post:
      tags:
        - Routing Sessions
      summary: Dispatch Session
      description: >-
        Dispatch a routing session: its routes, their operations in order, and
        the drivers of each route, in one transaction. Typically the body is
        built from a routing plan (`POST /operations/routing` or
        `/operations/routing/multi-fleet`). Routes without operations are
        skipped. Drivers then see their routes in `GET /operations/routes`.


        **Failure Modes:**

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

        - **403**: Insufficient permissions, `company_slug` is a company you
        cannot manage, or a driver is outside your company and its child
        companies

        - **404**: A driver does not exist

        - **409**: A session with this `slug` already exists

        - **422**: Invalid request body


        **Required Auth Scopes:**

        - `routing-sessions:manage`
      operationId: create_session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionCreate'
      responses:
        '201':
          description: >-
            Session created successfully. Returns the complete session with
            routes, operations, and driver assignments.
          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.
        '409':
          description: Conflict. Session slug already exists.
        '422':
          description: Unprocessable Entity. Validation failed.
        '500':
          description: Internal Server Error.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    SessionCreate:
      properties:
        slug:
          type: string
          title: Slug
          description: >-
            Unique session identifier you choose, e.g. a UUID. Used in the
            session URLs.
        company_slug:
          type: string
          title: Company Slug
          description: 'Owning company: yours or another company you can manage.'
        routes:
          items:
            $ref: '#/components/schemas/RouteCreate'
          type: array
          minItems: 1
          title: Routes
          description: Routes to create within this session.
      type: object
      required:
        - slug
        - company_slug
        - routes
      title: SessionCreate
      description: >-
        Top-level dispatch payload — creates session + routes + operations +
        drivers.
      examples:
        - company_slug: acme-mobility
          routes:
            - drivers:
                - driver_id: 57
              end_at: '2026-11-30T09:40:00Z'
              operations:
                - additional_notes: Battery level (12.0%) below threshold (20.0%)
                  address: Via Torino 2, 20123 Milano MI
                  estimated_arrive: '2026-11-30T08:14:00Z'
                  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'
                  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
    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
    RouteCreate:
      properties:
        route_identifier:
          type: string
          title: Route Identifier
          description: Unique route identifier within the session.
        reroute_enabled:
          type: boolean
          title: Reroute Enabled
          description: Whether the route can be re-optimized while it runs (reroute).
          default: false
        routing_parameters:
          additionalProperties: true
          type: object
          title: Routing Parameters
          description: >-
            Vehicle and shift parameters used when the route is rerouted:
            `start_coords` and `end_coords` (`{latitude, longitude}`),
            `start_time`, `max_duration` (minutes), `max_capacities`,
            `start_capacities`, and optionally `refill_capacities`,
            `depot_service_time`, `max_depot_refills`. Missing keys use
            defaults.
        operations_parameters:
          additionalProperties: true
          type: object
          title: Operations Parameters
          description: >-
            Free-form data stored with the route and returned as is, e.g. the
            parameters used to generate its operations.
        start_at:
          type:
            - string
            - 'null'
          format: date-time
          title: Start At
          description: Route start time.
        end_at:
          type:
            - string
            - 'null'
          format: date-time
          title: End At
          description: Route end time.
        total_distance:
          type:
            - number
            - 'null'
          title: Total Distance
          description: Total planned distance in kilometres.
        operations:
          items:
            $ref: '#/components/schemas/OperationCreate'
          type: array
          title: Operations
          description: >-
            Ordered list of operations for this route. May be empty: a route
            with nothing to do is accepted but not saved (nor its drivers), so
            one idle vehicle does not fail the dispatch of the others.
        drivers:
          items:
            $ref: '#/components/schemas/DriverAssignment'
          type: array
          title: Drivers
          description: >-
            Drivers to assign to this route: active users of your company or its
            child companies.
      type: object
      required:
        - route_identifier
        - operations
      title: RouteCreate
      description: Single route within a session (dispatch payload).
      examples:
        - drivers:
            - driver_id: 57
          end_at: '2026-11-30T09:40:00Z'
          operations:
            - additional_notes: Battery level (12.0%) below threshold (20.0%)
              address: Via Torino 2, 20123 Milano MI
              estimated_arrive: '2026-11-30T08:14:00Z'
              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
          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
    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.
    OperationCreate:
      properties:
        step:
          type: integer
          title: Step
          description: Order of this operation in the route.
        task_type:
          type: string
          title: Task Type
          description: >-
            What the operator does at the stop, e.g. `pickup`, `dropoff`,
            `battery_swap`, `recharge_pickup`, `start_charge`, `end_charge`.
            Completing a `recharge_pickup` adds a `start_charge` right after it.
        latitude:
          type: number
          title: Latitude
          description: Latitude (WGS84).
        longitude:
          type: number
          title: Longitude
          description: Longitude (WGS84).
        provider:
          type: string
          title: Provider
          description: Fleet the vehicle belongs to; the Copilot sends your company slug.
        address:
          type:
            - string
            - 'null'
          title: Address
          description: Street address (optional).
        vehicle_properties:
          additionalProperties: true
          type:
            - object
            - 'null'
          title: Vehicle Properties
          description: >-
            Snapshot of the vehicle at planning time, e.g. the
            `vehicle_properties` of a suggested operation.
        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 for the stop, e.g. the `routing_parameters` of the
            routing plan step (`capacity_delta`, `profit`).
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Optional free-text notes about the task.
      type: object
      required:
        - step
        - task_type
        - latitude
        - longitude
        - provider
        - estimated_arrive
      title: OperationCreate
      description: Single operation within a route (dispatch payload).
      examples:
        - additional_notes: Battery level (12.0%) below threshold (20.0%)
          address: Via Torino 2, 20123 Milano MI
          estimated_arrive: '2026-11-30T08:14:00Z'
          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
    DriverAssignment:
      properties:
        driver_id:
          type: integer
          title: Driver Id
          description: User ID of the driver (`user_id` of a driver).
      type: object
      required:
        - driver_id
      title: DriverAssignment
      description: Driver to assign to a route.
      examples:
        - driver_id: 57
    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.