> ## 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 Forecasted Demand

> Retrieve demand forecast predictions for your company, for the forecast type enabled for it and the applied filters. This endpoint automatically picks your company's only forecast type and returns time-series predictions aggregated by spatial zones.

**Failure Modes:**
- **400**: Invalid filters (unsupported location, granularity, or grid type) or multiple forecast types configured requiring explicit selection
- **401**: Invalid or missing Bearer token credentials
- **403**: Insufficient permissions (missing 'forecast:read' scope or no forecast access)
- **404**: Your company has no forecasts configured, or the forecast type is not enabled for it
- **422**: Invalid request data that fails validation
- **500**: Missing configuration data, malformed prediction data, or inability to locate any viable predictions

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

**Supported Forecast Types:**
- `demand` - Demand forecast predictions aggregated by spatial zones.
- `unsatisfied-demand` - Unsatisfied demand forecast predictions aggregated by spatial zones.



## OpenAPI

````yaml /api-reference/openapi.json post /forecast
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:
  /forecast:
    post:
      tags:
        - Forecast
      summary: Get Forecasted Demand
      description: >-
        Retrieve demand forecast predictions for your company, for the forecast
        type enabled for it and the applied filters. This endpoint automatically
        picks your company's only forecast type and returns time-series
        predictions aggregated by spatial zones.


        **Failure Modes:**

        - **400**: Invalid filters (unsupported location, granularity, or grid
        type) or multiple forecast types configured requiring explicit selection

        - **401**: Invalid or missing Bearer token credentials

        - **403**: Insufficient permissions (missing 'forecast:read' scope or no
        forecast access)

        - **404**: Your company has no forecasts configured, or the forecast
        type is not enabled for it

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

        - **500**: Missing configuration data, malformed prediction data, or
        inability to locate any viable predictions


        **Required Auth Scopes:**

        - `forecast:read`


        **Supported Forecast Types:**

        - `demand` - Demand forecast predictions aggregated by spatial zones.

        - `unsatisfied-demand` - Unsatisfied demand forecast predictions
        aggregated by spatial zones.
      operationId: get_forecast
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ForecastFilters'
        required: true
      responses:
        '200':
          description: >-
            Successfully retrieved forecast predictions with time periods and
            zone-aggregated values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForecastReponse'
        '400':
          description: >-
            Bad Request. Location, time granularity, prediction horizon, or grid
            type not supported by the forecast configuration, or multiple
            forecast types found requiring explicit selection.
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: >-
            Forbidden. Insufficient permissions (missing 'forecast:read' scope
            or no forecast access).
        '404':
          description: >-
            Not Found. Your company has no forecasts configured, or the forecast
            type is not enabled for it.
        '422':
          description: >-
            Unprocessable Entity. Request body contains invalid data that fails
            validation.
        '500':
          description: >-
            Internal Server Error. Missing forecast or data ingestion
            configuration, malformed prediction data structure, or inability to
            locate any viable prediction files.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    ForecastFilters:
      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: ForecastFilters
      description: |-
        Defines the filters applicable to a forecast 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'
    ForecastReponse:
      properties:
        periods:
          items:
            type: string
            format: date-time
          type: array
          title: Periods
          description: Start of each forecast time bucket (UTC), in order
        zones:
          additionalProperties:
            items:
              type: number
            type: array
          type: object
          title: Zones
          description: >-
            Forecasted value per zone: zone id -> one value per entry of
            `periods`, in the same order. Zones whose values are all zero are
            left out.
          examples:
            - '1042':
                - 3.2
                - 4.1
                - 2.7
              '1043':
                - 1.4
                - 1.9
                - 0.8
      type: object
      required:
        - periods
        - zones
      title: ForecastReponse
      description: >-
        Represents the response structure for a forecast request.


        This schema includes the time periods and forecasted values for
        different zones.
      examples:
        - periods:
            - '2026-11-30T08:00:00Z'
            - '2026-11-30T09:00:00Z'
            - '2026-11-30T10:00:00Z'
          zones:
            '1042':
              - 3.2
              - 4.1
              - 2.7
            '1043':
              - 1.4
              - 1.9
              - 0.8
    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.