> ## 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 Transit Service Delivery

> Scheduled versus operated trips of a transit network over a period. A scheduled trip counts as operated when realtime data shows it ran; otherwise it is `cancelled` when the feed says so (only some feeds do) or `missing` (no realtime data: not necessarily cancelled). Returns the totals, the figures by line and by day, headway regularity, the average active fleet by hour, and the missing trips by hour, time band and line.

Days with no realtime data at all are left out of every figure (`coverage.days_without_data`); on days with partial data, trips outside the observed hours are left out too.

**Failure Modes:**
- **401**: Token is missing or invalid
- **403**: Insufficient permissions, transit analytics not enabled, or the location is not configured for it
- **422**: Invalid filters (dates in the wrong order, more than 31 days, `hour_from` after `hour_to`), or too much data: narrow the date range
- **502**: Transit data unavailable
- **503**: The timetable is unavailable

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



## OpenAPI

````yaml /api-reference/openapi.json get /copilot/analytics/transit/service-delivery
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:
  /copilot/analytics/transit/service-delivery:
    get:
      tags:
        - Transit Analytics
      summary: Get Transit Service Delivery
      description: >-
        Scheduled versus operated trips of a transit network over a period. A
        scheduled trip counts as operated when realtime data shows it ran;
        otherwise it is `cancelled` when the feed says so (only some feeds do)
        or `missing` (no realtime data: not necessarily cancelled). Returns the
        totals, the figures by line and by day, headway regularity, the average
        active fleet by hour, and the missing trips by hour, time band and line.


        Days with no realtime data at all are left out of every figure
        (`coverage.days_without_data`); on days with partial data, trips outside
        the observed hours are left out too.


        **Failure Modes:**

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

        - **403**: Insufficient permissions, transit analytics not enabled, or
        the location is not configured for it

        - **422**: Invalid filters (dates in the wrong order, more than 31 days,
        `hour_from` after `hour_to`), or too much data: narrow the date range

        - **502**: Transit data unavailable

        - **503**: The timetable is unavailable


        **Required Auth Scopes:**

        - `copilot:analytics`
      operationId: get_transit_service_delivery
      parameters:
        - name: location
          in: query
          required: true
          schema:
            type: string
            minLength: 1
            description: >-
              Transit network location, e.g. `milan`: one of the locations
              configured for this transit analysis in your company.
            title: Location
          description: >-
            Transit network location, e.g. `milan`: one of the locations
            configured for this transit analysis in your company.
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date
            description: First service day, ISO 8601 date, e.g. `2026-10-01`.
            title: Start Date
          description: First service day, ISO 8601 date, e.g. `2026-10-01`.
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date
            description: >-
              Last service day, included (ISO 8601 date, e.g. `2026-10-31`). Not
              before `start_date`; at most 31 days in all.
            title: End Date
          description: >-
            Last service day, included (ISO 8601 date, e.g. `2026-10-31`). Not
            before `start_date`; at most 31 days in all.
        - name: lines
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            maxItems: 40
            description: >-
              Line names to keep, case-insensitive, e.g. `lines=1&lines=12`; a
              name covers every route that carries it. Combined with `route_ids`
              as a union. Empty = all lines.
            default: []
            title: Lines
          description: >-
            Line names to keep, case-insensitive, e.g. `lines=1&lines=12`; a
            name covers every route that carries it. Combined with `route_ids`
            as a union. Empty = all lines.
        - name: route_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
            maxItems: 40
            description: >-
              Exact GTFS `route_id`s to keep, e.g. `route_ids=R90`. Combined
              with `lines` as a union. Empty = all lines.
            default: []
            title: Route Ids
          description: >-
            Exact GTFS `route_id`s to keep, e.g. `route_ids=R90`. Combined with
            `lines` as a union. Empty = all lines.
        - name: direction
          in: query
          required: false
          schema:
            type:
              - integer
              - 'null'
            maximum: 1
            minimum: 0
            description: GTFS `direction_id` to keep (0 or 1). Omit for both.
            title: Direction
          description: GTFS `direction_id` to keep (0 or 1). Omit for both.
        - name: hour_from
          in: query
          required: false
          schema:
            type: integer
            maximum: 23
            minimum: 0
            description: >-
              First hour of the day to include (0-23, local time of the
              network), by scheduled time.
            default: 0
            title: Hour From
          description: >-
            First hour of the day to include (0-23, local time of the network),
            by scheduled time.
        - name: hour_to
          in: query
          required: false
          schema:
            type: integer
            maximum: 23
            minimum: 0
            description: >-
              Last hour of the day to include (0-23, local time), not before
              `hour_from`.
            default: 23
            title: Hour To
          description: >-
            Last hour of the day to include (0-23, local time), not before
            `hour_from`.
        - name: day_type
          in: query
          required: false
          schema:
            enum:
              - all
              - weekday
              - saturday
              - sunday
            type: string
            description: >-
              Days to keep: `all`, `weekday` (Monday to Friday), `saturday` or
              `sunday`.
            default: all
            title: Day Type
          description: >-
            Days to keep: `all`, `weekday` (Monday to Friday), `saturday` or
            `sunday`.
      responses:
        '200':
          description: Service delivery computed. Summary, breakdowns, coverage.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceDeliveryResult'
        '401':
          description: Unauthorized. Token is missing or invalid.
        '403':
          description: Forbidden. Transit analysis not enabled for location.
        '422':
          description: Unprocessable Entity. Validation failed.
        '502':
          description: Bad Gateway. Transit data unavailable.
        '503':
          description: Service Unavailable. Transit schedule unavailable.
      security:
        - HTTPBearer: []
        - HTTPBearer: []
components:
  schemas:
    ServiceDeliveryResult:
      properties:
        summary:
          $ref: '#/components/schemas/ServiceDeliverySummary'
        by_line:
          items:
            $ref: '#/components/schemas/DeliveryLine'
          type: array
          title: By Line
        by_day:
          items:
            $ref: '#/components/schemas/DeliveryDay'
          type: array
          title: By Day
        active_fleet_by_hour:
          items:
            $ref: '#/components/schemas/FleetHour'
          type: array
          title: Active Fleet By Hour
        missing_trips:
          items:
            $ref: '#/components/schemas/MissingTrip'
          type: array
          title: Missing Trips
        missing_trips_by_hour:
          items:
            $ref: '#/components/schemas/MissingTripsHour'
          type: array
          title: Missing Trips By Hour
          default: []
        missing_trips_by_time_band:
          additionalProperties:
            type: integer
          type: object
          title: Missing Trips By Time Band
          default: {}
        missing_trips_by_line_and_band:
          items:
            $ref: '#/components/schemas/MissingTripsLine'
          type: array
          title: Missing Trips By Line And Band
          default: []
        coverage:
          $ref: '#/components/schemas/Coverage'
        definition:
          $ref: '#/components/schemas/Definition'
        caveats:
          items:
            type: string
          type: array
          title: Caveats
      type: object
      required:
        - summary
        - by_line
        - by_day
        - active_fleet_by_hour
        - missing_trips
        - coverage
        - definition
        - caveats
      title: ServiceDeliveryResult
      description: >-
        Scheduled vs operated trips.


        Service days with zero realtime observations for the whole feed scope
        (no

        vehicle position trip and no trip-update event for that service date)
        are

        excluded from every scheduled-trip denominator and aggregate; they are

        listed in ``coverage.days_without_data`` and flagged by the

        ``days_without_realtime_data_excluded`` caveat.


        On partial realtime days (``coverage.partial_days``, caveat

        ``partial_realtime_days``) every scheduled trip starting before the
        first

        or after the last realtime observation of that day (trip updates or
        vehicle

        positions) is excluded from every denominator, observed or not, so a
        feed

        outage is neither reported as missed service nor inflates operated %.

        Trips without stop times (no known start) stay on partial days only when

        observed. Gaps inside the observed window (flagged by the low trip share

        rule) cannot be told apart from missed trips and still count as missing.


        A scheduled trip that was not operated is ``cancelled`` when its trip
        update

        says CANCELED, otherwise it is counted in ``missing_trips``: not
        observed

        (no realtime data), not necessarily cancelled. Only some feeds send

        cancellations; for the others ``cancelled_trips`` is 0.
      examples:
        - active_fleet_by_hour:
            - average_active_vehicles: 398.2
              hour: 8
            - average_active_vehicles: 301.7
              hour: 13
          by_day:
            - cancelled: 18
              operated: 6322
              operated_pct: 97.6
              scheduled: 6480
              service_date: '2026-10-01'
            - cancelled: 25
              operated: 6275
              operated_pct: 96.8
              scheduled: 6480
              service_date: '2026-10-02'
          by_line:
            - cancelled: 64
              headway_cv_observed: 0.42
              headway_cv_scheduled: 0.18
              operated: 8890
              operated_pct: 95.6
              route_id: R90
              route_short_name: '90'
              scheduled: 9300
            - cancelled: 0
              headway_cv_observed: 0.27
              headway_cv_scheduled: 0.21
              operated: 5371
              operated_pct: 99.1
              route_id: R73
              route_short_name: '73'
              scheduled: 5420
          caveats:
            - holiday_exceptions_not_in_timetable
            - days_without_realtime_data_excluded
            - partial_realtime_days
          coverage:
            days_requested: 31
            days_with_data: 30
            days_without_data:
              - '2026-10-12'
            first_available_date: '2026-06-02'
            partial_days:
              - '2026-10-20'
            saturdays_with_data: 5
            sundays_with_data: 4
            weekdays_with_data: 21
          definition:
            on_time_window_seconds:
              - -60
              - 180
            very_late_seconds: 600
          missing_trips:
            - direction_id: 0
              first_departure: '07:42'
              route_id: R90
              route_short_name: '90'
              service_date: '2026-10-01'
            - direction_id: 1
              first_departure: '18:05'
              route_id: R90
              route_short_name: '90'
              service_date: '2026-10-02'
          missing_trips_by_hour:
            - hour: 7
              missing_trips: 512
            - hour: 18
              missing_trips: 468
          missing_trips_by_line_and_band:
            - afternoon: 102
              evening: 93
              morning: 151
              route_id: R90
              route_short_name: '90'
              total: 346
              unknown_start: 0
          missing_trips_by_time_band:
            afternoon: 1310
            evening: 1415
            morning: 1840
            unknown_start: 55
          summary:
            cancelled_trips: 530
            missing_trips: 4620
            operated_pct: 97.2
            operated_trips: 181250
            peak_active_vehicles: 412.5
            scheduled_trips: 186400
    ServiceDeliverySummary:
      properties:
        scheduled_trips:
          type: integer
          title: Scheduled Trips
        operated_trips:
          type: integer
          title: Operated Trips
        operated_pct:
          type:
            - number
            - 'null'
          title: Operated Pct
        missing_trips:
          type: integer
          title: Missing Trips
        cancelled_trips:
          type: integer
          title: Cancelled Trips
          default: 0
        peak_active_vehicles:
          type:
            - number
            - 'null'
          title: Peak Active Vehicles
      type: object
      required:
        - scheduled_trips
        - operated_trips
        - operated_pct
        - missing_trips
        - peak_active_vehicles
      title: ServiceDeliverySummary
    DeliveryLine:
      properties:
        route_id:
          type: string
          title: Route Id
        route_short_name:
          type:
            - string
            - 'null'
          title: Route Short Name
        scheduled:
          type: integer
          title: Scheduled
        operated:
          type: integer
          title: Operated
        operated_pct:
          type:
            - number
            - 'null'
          title: Operated Pct
        cancelled:
          type: integer
          title: Cancelled
          default: 0
        headway_cv_observed:
          type:
            - number
            - 'null'
          title: Headway Cv Observed
        headway_cv_scheduled:
          type:
            - number
            - 'null'
          title: Headway Cv Scheduled
      type: object
      required:
        - route_id
        - route_short_name
        - scheduled
        - operated
        - operated_pct
        - headway_cv_observed
        - headway_cv_scheduled
      title: DeliveryLine
    DeliveryDay:
      properties:
        service_date:
          type: string
          format: date
          title: Service Date
        scheduled:
          type: integer
          title: Scheduled
        operated:
          type: integer
          title: Operated
        cancelled:
          type: integer
          title: Cancelled
          default: 0
        operated_pct:
          type:
            - number
            - 'null'
          title: Operated Pct
      type: object
      required:
        - service_date
        - scheduled
        - operated
        - operated_pct
      title: DeliveryDay
    FleetHour:
      properties:
        hour:
          type: integer
          title: Hour
        average_active_vehicles:
          type: number
          title: Average Active Vehicles
      type: object
      required:
        - hour
        - average_active_vehicles
      title: FleetHour
    MissingTrip:
      properties:
        service_date:
          type: string
          format: date
          title: Service Date
        route_id:
          type: string
          title: Route Id
        route_short_name:
          type:
            - string
            - 'null'
          title: Route Short Name
        direction_id:
          type:
            - integer
            - 'null'
          title: Direction Id
        first_departure:
          type:
            - string
            - 'null'
          title: First Departure
      type: object
      required:
        - service_date
        - route_id
        - route_short_name
        - direction_id
        - first_departure
      title: MissingTrip
    MissingTripsHour:
      properties:
        hour:
          type: integer
          title: Hour
        missing_trips:
          type: integer
          title: Missing Trips
      type: object
      required:
        - hour
        - missing_trips
      title: MissingTripsHour
    MissingTripsLine:
      properties:
        route_id:
          type: string
          title: Route Id
        route_short_name:
          type:
            - string
            - 'null'
          title: Route Short Name
        morning:
          type: integer
          title: Morning
        afternoon:
          type: integer
          title: Afternoon
        evening:
          type: integer
          title: Evening
        unknown_start:
          type: integer
          title: Unknown Start
        total:
          type: integer
          title: Total
      type: object
      required:
        - route_id
        - route_short_name
        - morning
        - afternoon
        - evening
        - unknown_start
        - total
      title: MissingTripsLine
      description: Missing trips of one route per time band (see ServiceDeliveryResult).
    Coverage:
      properties:
        first_available_date:
          type:
            - string
            - 'null'
          format: date
          title: First Available Date
        days_without_data:
          items:
            type: string
            format: date
          type: array
          title: Days Without Data
        partial_days:
          items:
            type: string
            format: date
          type: array
          title: Partial Days
          default: []
        days_requested:
          type: integer
          title: Days Requested
          default: 0
        days_with_data:
          type: integer
          title: Days With Data
          default: 0
        weekdays_with_data:
          type: integer
          title: Weekdays With Data
          default: 0
        saturdays_with_data:
          type: integer
          title: Saturdays With Data
          default: 0
        sundays_with_data:
          type: integer
          title: Sundays With Data
          default: 0
      type: object
      required:
        - first_available_date
        - days_without_data
      title: Coverage
      description: >-
        Requested days vs days with realtime data.


        ``partial_days`` are days with data whose realtime feed covers only part

        of the timetable (see ``_partial_days``); they are also days with data.

        The trip-share part of that rule is relative to the requested range: it

        compares each day with the median day of the same request, so a range
        made

        only of equally thin days is not flagged by it.
    Definition:
      properties:
        on_time_window_seconds:
          prefixItems:
            - type: integer
            - type: integer
          type: array
          maxItems: 2
          minItems: 2
          title: On Time Window Seconds
        very_late_seconds:
          type: integer
          title: Very Late Seconds
          default: 600
      type: object
      required:
        - on_time_window_seconds
      title: Definition
  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.