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

# Get Rebalancing Suggestions

> **Deprecated:** use `POST /operations/suggest`, which supports configurable strategies.

Generate actionable rebalancing suggestions for zones based on imbalance data and vehicle status. This endpoint analyzes current vehicle distribution and battery levels to recommend operations such as pickups, dropoffs, and battery swaps to optimize service efficiency and meet demand.

**Failure Modes:**
- **400**: Location, granularity or grid not enabled for your company
- **401**: Invalid or missing authentication credentials
- **403**: Insufficient permissions
- **404**: Your company has no fleet or forecasts configured
- **422**: Invalid request data that fails validation
- **500**: Prediction data unavailable, configuration not loaded, or provider communication failure
- **501**: Unsupported provider specified in configuration

**Required Auth Scopes:**
- `rebalance:read`



## OpenAPI

````yaml /api-reference/openapi.json post /operations/rebalance
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/rebalance:
    post:
      tags:
        - Operations
      summary: Get Rebalancing Suggestions
      description: >-
        **Deprecated:** use `POST /operations/suggest`, which supports
        configurable strategies.


        Generate actionable rebalancing suggestions for zones based on imbalance
        data and vehicle status. This endpoint analyzes current vehicle
        distribution and battery levels to recommend operations such as pickups,
        dropoffs, and battery swaps to optimize service efficiency and meet
        demand.


        **Failure Modes:**

        - **400**: Location, granularity or grid not enabled for your company

        - **401**: Invalid or missing authentication credentials

        - **403**: Insufficient permissions

        - **404**: Your company has no fleet or forecasts configured

        - **422**: Invalid request data that fails validation

        - **500**: Prediction data unavailable, configuration not loaded, or
        provider communication failure

        - **501**: Unsupported provider specified in configuration


        **Required Auth Scopes:**

        - `rebalance:read`
      operationId: get_rebalancing_suggestions
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RebalancingFilters'
        required: true
      responses:
        '200':
          description: >-
            Rebalancing suggestions retrieved successfully with recommended
            operations for optimization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RebalancingResponse'
        '400':
          description: >-
            Bad Request. Location, granularity or grid not enabled for your
            company.
        '401':
          description: Unauthorized. Invalid or missing credentials.
        '403':
          description: Forbidden. Insufficient permissions.
        '422':
          description: Unprocessable Entity. Invalid request data that fails validation.
        '500':
          description: >-
            Internal Server Error. Prediction data unavailable, configuration
            not loaded, or system error.
        '501':
          description: >-
            Not Implemented. Provider specified in configuration is not
            supported for rebalancing operations.
      deprecated: true
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    RebalancingFilters:
      properties:
        time_granularity_minutes:
          type: integer
          title: Time Granularity Minutes
          description: >-
            Length of each forecast time bucket in minutes, e.g. 60. Together
            with `prediction_horizon_size` it must match one of the horizons
            enabled for your company; a 400 response lists them.
        prediction_horizon_size:
          type: integer
          title: Prediction Horizon Size
          description: >-
            Size of the prediction horizon in time steps (each one long
            `time_granularity_minutes` minutes)
        grid:
          $ref: '#/components/schemas/GridFilters'
          description: Grid schema defining the spatial structure for the forecast
        zones_whitelist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Whitelist
          description: >-
            Optional list of zone IDs to include in the response. If provided,
            only zones in this list will be returned.
        zones_blacklist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Blacklist
          description: >-
            Optional list of zone IDs to exclude from the response. Takes
            precedence over zones_whitelist when both are provided.
        operation_types:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Operation Types
          description: >-
            Operation types to generate: any of `battery_swap`, `pickup`,
            `dropoff`. Omit for all three.
        override_strat:
          $ref: '#/components/schemas/PartialRebalanceConfig'
          description: >-
            Partial override for strategy configuration. Only provided fields
            will override the default configuration, others will use default
            values.
          examples:
            - null
        vehicle_pool:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Vehicle Pool
          description: >-
            Optional list of vehicle IDs to filter operations to. When provided,
            only vehicles in this pool will be considered for rebalancing
            operations.
        complete_rebalance:
          type: boolean
          title: Complete Rebalance
          description: >-
            When false, the number of pickup and dropoff operations will be
            balanced. If different numbers are generated, suggestions will be
            cut based on urgency.
          default: true
        upstream_tasks:
          items:
            $ref: '#/components/schemas/UpstreamTask'
          type:
            - array
            - 'null'
          title: Upstream Tasks
          description: >-
            Optional list of upstream tasks to be converted into operations.
            These tasks will be enriched with spatial and zone information from
            the retrieved vehicles and included in the suggestions list.
      type: object
      required:
        - time_granularity_minutes
        - prediction_horizon_size
        - grid
      title: RebalancingFilters
      description: |-
        Defines the filters applicable to a rebalancing request.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use ``OperationsGenerationConfiguration`` from the ``/suggest`` endpoint
            instead.

        This schema includes parameters to filter operation types and override
        default strategy configurations.
      deprecated: true
      examples:
        - complete_rebalance: true
          grid:
            grid_type: squares
            location: milan
            tile_size: 1000
          operation_types:
            - battery_swap
            - pickup
            - dropoff
          prediction_horizon_size: 3
          time_granularity_minutes: 60
          zones_whitelist:
            - '1042'
            - '1043'
    RebalancingResponse:
      properties:
        periods:
          items:
            type: string
            format: date-time
          type: array
          title: Periods
          description: list of time buckets for which the suggestions are provided
        suggestions:
          items:
            $ref: '#/components/schemas/Operation'
          type: array
          title: Suggestions
          description: list of rebalancing suggestions
      type: object
      required:
        - periods
        - suggestions
      title: RebalancingResponse
      description: >-
        Represents the response structure for a rebalancing request.


        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint and ``OperationsGenerationResponse`` instead.

        This schema includes a list of suggested operations for rebalancing

        vehicles across different zones and time periods.

        It also includes the time periods for which the suggestions are
        provided.
      deprecated: true
      examples:
        - periods:
            - '2026-11-30T08:00:00Z'
            - '2026-11-30T09:00:00Z'
            - '2026-11-30T10:00:00Z'
          suggestions:
            - additional_notes: Battery level (12.0%) below threshold (20.0%)
              generated_at: '2026-11-30T07:55:00Z'
              latitude: 45.4642
              longitude: 9.1856
              operation_type: battery_swap
              priority: high
              priority_value: 2.4
              vehicle_id: acme-sc-0193
              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
              zone_id: '1042'
            - additional_notes: 'Zone surplus 1.0 vehicles (threshold: 1.5)'
              generated_at: '2026-11-30T07:55:00Z'
              latitude: 45.4671
              longitude: 9.1883
              operation_type: pickup
              priority: medium
              priority_value: 2.1
              valid_from: '2026-11-30T08:00:00Z'
              valid_until: '2026-11-30T09:00:00Z'
              vehicle_id: acme-sc-0457
              zone_id: '1042'
    GridFilters:
      properties:
        grid_type:
          type: string
          enum:
            - squares
            - categorical
            - hdbscan
            - agent-3
            - agent-2
            - agent-1
            - agent-4
            - agent-5
            - agent-6
            - agent-7
            - agent-8
            - agent-9
            - custom-polygons
          title: Grid Type
          description: >-
            Type of spatial grid, e.g. `squares` for a regular grid of square
            tiles. Only the grid types (and tile sizes) enabled for your company
            are accepted; a 400 response lists them.
        tile_size:
          type:
            - integer
            - 'null'
          title: Tile Size
          description: >-
            Side of each square tile in meters, e.g. 1000 for the `squares`
            grid. Leave empty for grid types without a tile size.
        location:
          type: string
          title: Location
          description: >-
            Location (city) of the grid, e.g. `milan`. Only the locations
            enabled for your company are accepted; a 400 response lists them.
      type: object
      required:
        - grid_type
        - location
      title: GridFilters
      description: >-
        Schema for filtering grid forecasts.

        This schema defines the parameters used to filter grid forecasts based
        on

        grid type, tile size, and location. It is used to ensure that the
        forecast

        requests are structured correctly and contain all necessary information.
    PartialRebalanceConfig:
      properties:
        battery_swap:
          anyOf:
            - $ref: '#/components/schemas/PartialBatterySwapConfig'
            - type: boolean
          title: Battery Swap
          description: >-
            Partial configuration for the battery swap strategy. Set to false to
            disable battery swap operations.
        pickup:
          anyOf:
            - $ref: '#/components/schemas/PartialPickupConfig'
            - type: boolean
          title: Pickup
          description: >-
            Partial configuration for the pickup strategy. Set to false to
            disable pickup operations.
        dropoff:
          anyOf:
            - $ref: '#/components/schemas/PartialDropoffConfig'
            - type: boolean
          title: Dropoff
          description: >-
            Partial configuration for the dropoff strategy. Set to false to
            disable dropoff operations.
      type: object
      title: PartialRebalanceConfig
      description: |-
        Partial configuration for rebalancing strategies override.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        All fields are optional to allow partial updates of specific strategies
        while keeping existing configuration for others. Set a strategy to false
        to disable it completely for this request.
      deprecated: true
    UpstreamTask:
      properties:
        vehicle_id:
          type: string
          title: Vehicle Id
          description: Vehicle ID associated with the task
        operation_type:
          type: string
          title: Operation Type
          description: Type of operation, e.g., pickup, dropoff, or battery swap
        priority:
          type: string
          enum:
            - low
            - medium
            - high
            - must
          title: Priority
          description: Priority level of the task, e.g., low, medium, or high
        priority_value:
          type:
            - number
            - 'null'
          minimum: 0
          title: Priority Value
          description: >-
            Continuous profit value (see Operation.priority_value). Optional:
            when omitted, the suggest service computes a default using the
            operation type's base profit at neutral urgency (1.0).
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Free-text notes about the task, e.g. imbalance deficit or idle time.
        generated_at:
          type: string
          format: date-time
          title: Generated At
          description: Timestamp when the task was generated
        valid_from:
          type:
            - string
            - 'null'
          format: date-time
          title: Valid From
          description: Start of the validity window for this task
        valid_until:
          type:
            - string
            - 'null'
          format: date-time
          title: Valid Until
          description: End of the validity window for this task
        title:
          type: string
          title: Title
          description: Title or description of the task
      type: object
      required:
        - vehicle_id
        - operation_type
        - priority
        - generated_at
        - title
      title: UpstreamTask
      description: >-
        Represents an upstream task to be converted into an operation.


        This schema includes details from an external task that will be
        transformed

        into a full operation with spatial and zone information.
      examples:
        - additional_notes: 'Reported by a customer: battery not charging'
          generated_at: '2026-11-30T07:30:00Z'
          operation_type: battery_swap
          priority: must
          title: Check battery of acme-sc-0311
          valid_until: '2026-11-30T12:00:00Z'
          vehicle_id: acme-sc-0311
    Operation:
      properties:
        vehicle_id:
          type:
            - string
            - 'null'
          title: Vehicle Id
          description: >-
            Vehicle ID associated with the operation. Null for dropoffs
            generated by the suggestion strategies: a dropoff targets a zone,
            not a vehicle.
        latitude:
          type: number
          title: Latitude
          description: Latitude of the operation's location
        longitude:
          type: number
          title: Longitude
          description: Longitude of the operation's location
        zone_id:
          type: string
          title: Zone Id
          description: Zone ID where the operation is located
        operation_type:
          type: string
          title: Operation Type
          description: Type of operation, e.g., pickup, dropoff, or battery swap
        priority:
          type: string
          enum:
            - low
            - medium
            - high
            - must
          title: Priority
          description: Priority level of the operation, e.g., low, medium, or high
        priority_value:
          type: number
          minimum: 0
          title: Priority Value
          description: >-
            Continuous profit value used by the routing solver. Computed by
            suggest strategies as base_profit_for_op_type * urgency_factor
            (urgency in [1.0, 2.0]). The 'priority' enum is metadata only,
            except 'must' which still triggers hard-include.
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: >-
            Free-text notes about the operation, e.g. imbalance deficit or idle
            time.
        battery_level:
          type:
            - number
            - 'null'
          title: Battery Level
          description: Current battery level of the vehicle, if applicable
        generated_at:
          type: string
          format: date-time
          title: Generated At
          description: Timestamp when the operation was generated
        valid_from:
          type:
            - string
            - 'null'
          format: date-time
          title: Valid From
          description: Start of the validity window for this operation
        valid_until:
          type:
            - string
            - 'null'
          format: date-time
          title: Valid Until
          description: End of the validity window for this operation
        vehicle_properties:
          $ref: '#/components/schemas/VehicleWithoutZone'
          description: >-
            Full vehicle snapshot at the time the operation was generated.
            Serializable to VehicleWithoutZone. Populated by suggest strategies
            and preserved through the routing response so callers can persist it
            to the DB.
      type: object
      required:
        - vehicle_id
        - latitude
        - longitude
        - zone_id
        - operation_type
        - priority
        - priority_value
        - generated_at
      title: Operation
      description: |-
        Represents an operation to be performed.

        This schema includes details such as the operation's location, type,
        priority, and associated vehicle.
      examples:
        - additional_notes: 'Zone surplus 1.0 vehicles (threshold: 1.5)'
          generated_at: '2026-11-30T07:55:00Z'
          latitude: 45.4671
          longitude: 9.1883
          operation_type: pickup
          priority: medium
          priority_value: 2.1
          valid_from: '2026-11-30T08:00:00Z'
          valid_until: '2026-11-30T09:00:00Z'
          vehicle_id: acme-sc-0457
          zone_id: '1042'
    PartialBatterySwapConfig:
      properties:
        threshold:
          type:
            - integer
            - 'null'
          title: Threshold
          description: Threshold value for the strategy, e.g., battery level
        urgency_levels:
          $ref: '#/components/schemas/PartialUrgencyLevel'
          description: Urgency levels for the strategy, e.g., low, medium, high
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Free-text notes for the strategy, e.g. battery level is low
        zones_whitelist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Whitelist
          description: >-
            Optional list of zone IDs to include for this specific strategy. If
            provided, only zones in this list will be considered for this
            strategy.
        zones_blacklist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Blacklist
          description: >-
            Optional list of zone IDs to exclude for this specific strategy.
            Takes precedence over zones_whitelist when both are provided.
      type: object
      title: PartialBatterySwapConfig
      description: |-
        Partial configuration for the battery swap strategy override.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        Inherits all optional fields from PartialStrategyConfig.
      deprecated: true
    PartialPickupConfig:
      properties:
        idle_time:
          anyOf:
            - $ref: '#/components/schemas/PartialStrategyConfig'
            - type: boolean
          title: Idle Time
          description: >-
            Configuration for the pickup strategy based on idle time. Set to
            false to disable idle time pickup operations.
        imbalance:
          anyOf:
            - $ref: '#/components/schemas/PartialStrategyConfig'
            - type: boolean
          title: Imbalance
          description: >-
            Configuration for the pickup strategy based on imbalance. Set to
            false to disable imbalance pickup operations.
      type: object
      title: PartialPickupConfig
      description: >-
        Partial configuration for the pickup strategy override.


        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        All fields are optional to allow partial updates. Set a sub-strategy to
        false

        to disable it completely for this request.
      deprecated: true
    PartialDropoffConfig:
      properties:
        threshold:
          type:
            - integer
            - 'null'
          title: Threshold
          description: Threshold value for the strategy, e.g., battery level
        urgency_levels:
          $ref: '#/components/schemas/PartialUrgencyLevel'
          description: Urgency levels for the strategy, e.g., low, medium, high
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Free-text notes for the strategy, e.g. battery level is low
        zones_whitelist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Whitelist
          description: >-
            Optional list of zone IDs to include for this specific strategy. If
            provided, only zones in this list will be considered for this
            strategy.
        zones_blacklist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Blacklist
          description: >-
            Optional list of zone IDs to exclude for this specific strategy.
            Takes precedence over zones_whitelist when both are provided.
      type: object
      title: PartialDropoffConfig
      description: |-
        Partial configuration for the dropoff strategy override.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        Inherits all optional fields from PartialStrategyConfig.
      deprecated: true
    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.
    PartialUrgencyLevel:
      properties:
        low:
          type:
            - number
            - 'null'
          title: Low
          description: Low urgency level, e.g., 50% battery level
        medium:
          type:
            - number
            - 'null'
          title: Medium
          description: Medium urgency level, e.g., 30% battery level
        high:
          type:
            - number
            - 'null'
          title: High
          description: High urgency level, e.g., 20% battery level
      type: object
      title: PartialUrgencyLevel
      description: |-
        Partial urgency levels for strategy overrides.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        All fields are optional to allow partial updates.
      deprecated: true
    PartialStrategyConfig:
      properties:
        threshold:
          type:
            - integer
            - 'null'
          title: Threshold
          description: Threshold value for the strategy, e.g., battery level
        urgency_levels:
          $ref: '#/components/schemas/PartialUrgencyLevel'
          description: Urgency levels for the strategy, e.g., low, medium, high
        additional_notes:
          type:
            - string
            - 'null'
          title: Additional Notes
          description: Free-text notes for the strategy, e.g. battery level is low
        zones_whitelist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Whitelist
          description: >-
            Optional list of zone IDs to include for this specific strategy. If
            provided, only zones in this list will be considered for this
            strategy.
        zones_blacklist:
          items:
            type: string
          type:
            - array
            - 'null'
          title: Zones Blacklist
          description: >-
            Optional list of zone IDs to exclude for this specific strategy.
            Takes precedence over zones_whitelist when both are provided.
      type: object
      title: PartialStrategyConfig
      description: |-
        Partial strategy configuration for overrides.

        .. deprecated::
            Only used by the deprecated ``/rebalance`` endpoint.
            Use the ``/suggest`` endpoint instead.

        All fields are optional to allow partial updates.
      deprecated: true
  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.