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

# Get Commuting Zone Analysis

> Classify zones as Residential, Commercial or Balanced from their rush-hour flows: a Residential zone sends more trips than it receives in the morning (7-9 UTC) and receives more in the evening (17-19 UTC); a Commercial zone does the opposite. Returns each zone's average morning and evening inflow and outflow, and a count per zone type.

**Failure Modes:**
- **400**: `precision` given with a zoning system other than `geohash7`
- **401**: Token is missing or invalid
- **403**: Insufficient permissions
- **404**: `no_data_binding` when the provider or location is not enabled for your company
- **422**: Invalid filter parameters

**Required Auth Scopes:**
- `copilot:analytics`



## OpenAPI

````yaml /api-reference/openapi.json get /copilot/zone-based/{provider}/commuting_zones
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:
  /copilot/zone-based/{provider}/commuting_zones:
    get:
      tags:
        - Zone Based Analytics
      summary: Get Commuting Zone Analysis
      description: >-
        Classify zones as Residential, Commercial or Balanced from their
        rush-hour flows: a Residential zone sends more trips than it receives in
        the morning (7-9 UTC) and receives more in the evening (17-19 UTC); a
        Commercial zone does the opposite. Returns each zone's average morning
        and evening inflow and outflow, and a count per zone type.


        **Failure Modes:**

        - **400**: `precision` given with a zoning system other than `geohash7`

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

        - **403**: Insufficient permissions

        - **404**: `no_data_binding` when the provider or location is not
        enabled for your company

        - **422**: Invalid filter parameters


        **Required Auth Scopes:**

        - `copilot:analytics`
      operationId: get_commuting_zones
      parameters:
        - name: provider
          in: path
          required: true
          schema:
            type: string
            description: >-
              Identifier of the mobility provider whose data you analyse, e.g.
              `acme-bikes`. It must be the provider of a data source enabled for
              your company's zone-based analytics; any other value is refused
              with 404 `no_data_binding` (`kind: source`). Your SWITCH contact
              tells you the provider identifiers and locations enabled for your
              company.
            title: Provider
          description: >-
            Identifier of the mobility provider whose data you analyse, e.g.
            `acme-bikes`. It must be the provider of a data source enabled for
            your company's zone-based analytics; any other value is refused with
            404 `no_data_binding` (`kind: source`). Your SWITCH contact tells
            you the provider identifiers and locations enabled for your company.
        - name: geolabel
          in: query
          required: true
          schema:
            type: string
            description: >-
              Location to analyse, e.g. `milan`: one of the locations (or their
              geolabels) that your company's zone-based analytics are enabled
              for with this provider. Any other value is refused with 404
              `no_data_binding` (`kind: location`).
            title: Geolabel
          description: >-
            Location to analyse, e.g. `milan`: one of the locations (or their
            geolabels) that your company's zone-based analytics are enabled for
            with this provider. Any other value is refused with 404
            `no_data_binding` (`kind: location`).
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: >-
              First day of the analysis period (ISO 8601, e.g.
              `2026-10-01T00:00:00Z`). Only the date part is used, as a UTC day.
            title: Start Date
          description: >-
            First day of the analysis period (ISO 8601, e.g.
            `2026-10-01T00:00:00Z`). Only the date part is used, as a UTC day.
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: >-
              Last day of the analysis period, included (ISO 8601, e.g.
              `2026-10-31T00:00:00Z`). Only the date part is used, as a UTC day.
            title: End Date
          description: >-
            Last day of the analysis period, included (ISO 8601, e.g.
            `2026-10-31T00:00:00Z`). Only the date part is used, as a UTC day.
        - name: start_hour
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 23
            minimum: 0
            description: >-
              First hour of the day to include (0-23, UTC), both bounds
              included. Applied only together with `end_hour`, and only by trip
              volume and shortage mapping.
            title: Start Hour
          description: >-
            First hour of the day to include (0-23, UTC), both bounds included.
            Applied only together with `end_hour`, and only by trip volume and
            shortage mapping.
        - name: end_hour
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 23
            minimum: 0
            description: >-
              Last hour of the day to include (0-23, UTC). Applied only together
              with `start_hour`, and only by trip volume and shortage mapping.
            title: End Hour
          description: >-
            Last hour of the day to include (0-23, UTC). Applied only together
            with `start_hour`, and only by trip volume and shortage mapping.
        - name: zoning_system_id
          in: query
          required: false
          schema:
            type: string
            description: >-
              Zoning system the zones belong to. Defaults to `geohash7` (geohash
              cells, whose size `precision` sets).
            default: geohash7
            title: Zoning System Id
          description: >-
            Zoning system the zones belong to. Defaults to `geohash7` (geohash
            cells, whose size `precision` sets).
        - name: precision
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 7
            minimum: 4
            description: >-
              Geohash precision to aggregate to (4-7). Only valid when
              zoning_system_id='geohash7', where it defaults to 7. Passing it
              with any other zoning system returns HTTP 400.
            title: Precision
          description: >-
            Geohash precision to aggregate to (4-7). Only valid when
            zoning_system_id='geohash7', where it defaults to 7. Passing it with
            any other zoning system returns HTTP 400.
      responses:
        '200':
          description: >-
            Commuting analysis retrieved. Per-zone flows and type, and a summary
            per type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommutingZonesResponse'
        '400':
          description: Bad Request. `precision` needs `geohash7` zoning.
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Insufficient permissions.
        '404':
          description: Not Found. Provider or location not enabled.
        '422':
          description: Unprocessable Entity. Validation failed.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    CommutingZonesResponse:
      properties:
        commuting_analysis:
          items:
            $ref: '#/components/schemas/ZoneCommutingData'
          type: array
          title: Commuting Analysis
        zone_type_summary:
          items:
            $ref: '#/components/schemas/ZoneTypeSummary'
          type: array
          title: Zone Type Summary
      type: object
      required:
        - commuting_analysis
        - zone_type_summary
      title: CommutingZonesResponse
      examples:
        - commuting_analysis:
            - context:
                population: 980
                top_pois:
                  - category: sustenance
                    count: 47
                  - category: leisure
                    count: 6
                transit_stops_total: 4
              evening_inflow: 6.3
              evening_outflow: 2.4
              geom:
                coordinates:
                  - - - 9.17496
                      - 45.45181
                    - - 9.17633
                      - 45.45181
                    - - 9.17633
                      - 45.45319
                    - - 9.17496
                      - 45.45319
                    - - 9.17496
                      - 45.45181
                type: Polygon
              morning_inflow: 2.1
              morning_outflow: 5.8
              total_flow: 16.6
              zone_id: u0nd8f3
              zone_label: u0nd8f3
              zone_latitude: 45.4525
              zone_longitude: 9.17564
              zone_type: Residential
            - context:
                population: 655
                top_pois:
                  - category: transportation
                    count: 22
                  - category: sustenance
                    count: 19
                transit_stops_total: 14
              evening_inflow: 3.5
              evening_outflow: 8.9
              geom:
                coordinates:
                  - - - 9.2038
                      - 45.48477
                    - - 9.20517
                      - 45.48477
                    - - 9.20517
                      - 45.48615
                    - - 9.2038
                      - 45.48615
                    - - 9.2038
                      - 45.48477
                type: Polygon
              morning_inflow: 9.7
              morning_outflow: 3.2
              total_flow: 25.3
              zone_id: u0ndc2q
              zone_label: u0ndc2q
              zone_latitude: 45.48546
              zone_longitude: 9.20448
              zone_type: Commercial
          zone_type_summary:
            - avg_total_flow: 7.9
              count: 214
              zone_type: Residential
            - avg_total_flow: 13.4
              count: 96
              zone_type: Commercial
            - avg_total_flow: 4.2
              count: 1310
              zone_type: Balanced
    ZoneCommutingData:
      properties:
        zone_id:
          type: string
          title: Zone Id
          description: Geohash7 zone id
          examples:
            - u33db27
        zone_label:
          type: string
          title: Zone Label
          description: Human label (falls back to zone_id)
        zone_latitude:
          type: number
          maximum: 90
          minimum: -90
          title: Zone Latitude
          examples:
            - 52.52
        zone_longitude:
          type: number
          maximum: 180
          minimum: -180
          title: Zone Longitude
          examples:
            - 13.4
        geom:
          additionalProperties: true
          type:
            - object
            - 'null'
          title: Geom
          description: >-
            Zone boundary as a GeoJSON geometry object (e.g. Polygon /
            MultiPolygon with WGS84 lon/lat coordinates). Null when the zone has
            no stored geometry.
          examples:
            - coordinates:
                - - - 13.4
                    - 52.52
                  - - 13.41
                    - 52.52
                  - - 13.41
                    - 52.53
                  - - 13.4
                    - 52.52
              type: Polygon
        context:
          $ref: '#/components/schemas/ZoneContext'
          description: Enriched zone metadata, when available
        morning_outflow:
          type: number
          minimum: 0
          title: Morning Outflow
          description: Avg starts in hours 7-9
        morning_inflow:
          type: number
          minimum: 0
          title: Morning Inflow
          description: Avg ends in hours 7-9
        evening_outflow:
          type: number
          minimum: 0
          title: Evening Outflow
          description: Avg starts in hours 17-19
        evening_inflow:
          type: number
          minimum: 0
          title: Evening Inflow
          description: Avg ends in hours 17-19
        total_flow:
          type: number
          minimum: 0
          title: Total Flow
          description: Sum of all four flow components
        zone_type:
          type: string
          title: Zone Type
          examples:
            - Residential
            - Commercial
            - Balanced
      type: object
      required:
        - zone_id
        - zone_label
        - zone_latitude
        - zone_longitude
        - morning_outflow
        - morning_inflow
        - evening_outflow
        - evening_inflow
        - total_flow
        - zone_type
      title: ZoneCommutingData
    ZoneTypeSummary:
      properties:
        zone_type:
          type: string
          title: Zone Type
          examples:
            - Residential
            - Commercial
            - Balanced
        count:
          type: integer
          minimum: 0
          title: Count
        avg_total_flow:
          type: number
          minimum: 0
          title: Avg Total Flow
      type: object
      required:
        - zone_type
        - count
        - avg_total_flow
      title: ZoneTypeSummary
    ZoneContext:
      properties:
        population:
          type:
            - number
            - 'null'
          title: Population
          description: WorldPop latest population estimate for the zone
        transit_stops_total:
          type:
            - integer
            - 'null'
          title: Transit Stops Total
          description: Combined public-transit stop count in the zone
        top_pois:
          items:
            $ref: '#/components/schemas/ZonePoiCount'
          type: array
          title: Top Pois
          description: Top POI categories by count (max 3)
      type: object
      title: ZoneContext
      description: Key context stats enriched from the SQL layer (standard_zoning_system).
    ZonePoiCount:
      properties:
        category:
          type: string
          title: Category
          examples:
            - sustenance
            - transportation
            - education
        count:
          type: integer
          minimum: 0
          title: Count
          examples:
            - 42
            - 18
            - 7
      type: object
      required:
        - category
        - count
      title: ZonePoiCount
      description: One POI category with its count (top categories per zone).
  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.