> ## 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 Imbalance Snapshot as GeoJSON

> Calculate and retrieve vehicle distribution imbalance as GeoJSON format for zones within a specified time range. This endpoint returns the same imbalance calculations as the standard imbalance endpoint but merged with spatial grid geometries in GeoJSON format for visualization purposes.

Imbalance is defined as the difference between actual deployed vehicles and forecasted demand per zone, helping identify zones with high demand and low supply for resource allocation optimization.

**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:**
- `imbalance:read`



## OpenAPI

````yaml /api-reference/openapi.json post /operations/imbalance/geojson
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/imbalance/geojson:
    post:
      tags:
        - Operations
      summary: Get Imbalance Snapshot as GeoJSON
      description: >-
        Calculate and retrieve vehicle distribution imbalance as GeoJSON format
        for zones within a specified time range. This endpoint returns the same
        imbalance calculations as the standard imbalance endpoint but merged
        with spatial grid geometries in GeoJSON format for visualization
        purposes.


        Imbalance is defined as the difference between actual deployed vehicles
        and forecasted demand per zone, helping identify zones with high demand
        and low supply for resource allocation optimization.


        **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:**

        - `imbalance:read`
      operationId: get_demand_imbalance_geojson
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImbalanceFilters'
        required: true
      responses:
        '200':
          description: >-
            Imbalance snapshot retrieved successfully as GeoJSON with spatial
            geometries and zone-wise imbalance data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImbalanceGeoJSONResponse'
        '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 imbalance operations.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    ImbalanceFilters:
      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.
      type: object
      required:
        - time_granularity_minutes
        - prediction_horizon_size
        - grid
      title: ImbalanceFilters
      description: |-
        Defines the filters applicable to an imbalance snapshot request.

        This schema includes parameters such as location, time granularity,
        prediction horizon, and grid details.
      examples:
        - grid:
            grid_type: squares
            location: milan
            tile_size: 1000
          prediction_horizon_size: 3
          time_granularity_minutes: 60
          zones_whitelist:
            - '1042'
            - '1043'
    ImbalanceGeoJSONResponse:
      properties:
        geojson:
          additionalProperties: true
          type: object
          title: Geojson
          description: >-
            GeoJSON FeatureCollection with one Polygon feature per zone; each
            feature's properties are `zone_id` and `imbalance` (one value per
            entry of `periods`).
          examples:
            - features:
                - geometry:
                    coordinates:
                      - - - 9.18
                          - 45.46
                        - - 9.1928
                          - 45.46
                        - - 9.1928
                          - 45.469
                        - - 9.18
                          - 45.469
                        - - 9.18
                          - 45.46
                    type: Polygon
                  properties:
                    zone_id: '1042'
                    imbalance:
                      - 2.5
                      - 1
                      - -0.5
                  type: Feature
                - geometry:
                    coordinates:
                      - - - 9.1928
                          - 45.46
                        - - 9.2056
                          - 45.46
                        - - 9.2056
                          - 45.469
                        - - 9.1928
                          - 45.469
                        - - 9.1928
                          - 45.46
                    type: Polygon
                  properties:
                    zone_id: '1043'
                    imbalance:
                      - -1.8
                      - -3.2
                      - -2.1
                  type: Feature
              type: FeatureCollection
        periods:
          items:
            type: string
            format: date-time
          type: array
          title: Periods
          description: List of time periods for which the imbalance is provided
      type: object
      required:
        - geojson
        - periods
      title: ImbalanceGeoJSONResponse
      description: |-
        Represents the GeoJSON response structure for an imbalance snapshot.

        This schema includes the GeoJSON representation of zones with their
        imbalance values and the corresponding time periods.
      examples:
        - geojson:
            features:
              - geometry:
                  coordinates:
                    - - - 9.18
                        - 45.46
                      - - 9.1928
                        - 45.46
                      - - 9.1928
                        - 45.469
                      - - 9.18
                        - 45.469
                      - - 9.18
                        - 45.46
                  type: Polygon
                properties:
                  zone_id: '1042'
                  imbalance:
                    - 2.5
                    - 1
                    - -0.5
                type: Feature
              - geometry:
                  coordinates:
                    - - - 9.1928
                        - 45.46
                      - - 9.2056
                        - 45.46
                      - - 9.2056
                        - 45.469
                      - - 9.1928
                        - 45.469
                      - - 9.1928
                        - 45.46
                  type: Polygon
                properties:
                  zone_id: '1043'
                  imbalance:
                    - -1.8
                    - -3.2
                    - -2.1
                type: Feature
            type: FeatureCollection
          periods:
            - '2026-11-30T08:00:00Z'
            - '2026-11-30T09:00:00Z'
            - '2026-11-30T10:00:00Z'
    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.
  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.