> ## Documentation Index
> Fetch the complete documentation index at: https://docs.skyvexsoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# File the PIREP

> Closes out the flight. The server:

1. Saves every entry from `flight_data` (or the legacy `flight_log`) as ACARS LOG rows.
2. Recomputes total `distance` by summing great-circle segments between the FLIGHT_PATH rows accumulated during `/flights/update`. If no FLIGHT_PATH rows exist, the dpt-to-arr great-circle distance is used.
3. Files the PIREP with the supplied `landing_rate`, `fuel_used`, `flight_time`, and any of the optional `zfw` / `block_fuel` / `block_time` / `level` / `route` fields.
4. Appends any `comments` as pilot comments on the PIREP.
5. Calls phpVMS's `submit()` which fires the `PirepFiled` event, handles diversions, and applies rank-based auto-approval.

`flight_time` is in **decimal hours** here (the server multiplies by 60 to store minutes). Either `uuid` or `tracking_id` may carry the PIREP ID.



## OpenAPI

````yaml /api-reference/openapi.json post /flights/complete
openapi: 3.1.0
info:
  title: Stratos Core API
  version: 0.3.0
  summary: >-
    The Stratos VA API contract — auth, pilot identity, reference data, and the
    flight lifecycle.
  description: >-
    The contract every Stratos desktop client speaks to a virtual airline's crew
    system. The reference implementation is the open-source [stratos-core-api
    phpVMS 7 module](https://github.com/SkyvexSoftware/stratos-core-api), but
    any backend can implement these endpoints — they're framework-agnostic.


    Every endpoint in this reference is documented under `/api/stratos` — that's
    the convention the phpVMS module uses, and what we recommend for
    consistency. You're free to mount the surface anywhere you like; the desktop
    client just uses whatever base URL is set in your Stratos airline
    configuration.


    ## Authentication


    Most endpoints require a Bearer token — the pilot's API key, obtained via
    `POST /pilot/login` or your OAuth flow. Send as `Authorization: Bearer
    <api_key>` on every authenticated request.


    Public (no token): `GET /` and `POST /pilot/login`.


    ## Conventions


    - JSON, `snake_case` field names.

    - Distances in nautical miles, weights in pounds, flight times in decimal
    hours (unless suffixed `_minutes`).

    - Coordinates are decimal degrees (WGS84).

    - CORS is wide-open; the client preflights every method.
servers:
  - url: '{baseUrl}'
    description: >-
      Your VA's Stratos API base — set this to whatever URL the Stratos client
      is pointed at, including any path prefix you chose to mount the surface
      under.
    variables:
      baseUrl:
        default: https://crew.example.com/api/stratos
        description: >-
          Full base URL including the path prefix (no trailing slash). The
          phpVMS reference module mounts under `/api/stratos`; if you mounted
          yours somewhere else (e.g. `https://api.youva.com/stratos/v1`), use
          that.
security:
  - BearerAuth: []
tags:
  - name: Pilot
    description: Authentication, profile, and career statistics.
  - name: Reference Data
    description: Static lookup data the client renders in UI.
  - name: Flights
    description: >-
      Browse the schedule, manage bids, and run the active-flight lifecycle
      (start, update, complete, cancel).
paths:
  /flights/complete:
    post:
      tags:
        - Flights
      summary: File the PIREP
      description: >-
        Closes out the flight. The server:


        1. Saves every entry from `flight_data` (or the legacy `flight_log`) as
        ACARS LOG rows.

        2. Recomputes total `distance` by summing great-circle segments between
        the FLIGHT_PATH rows accumulated during `/flights/update`. If no
        FLIGHT_PATH rows exist, the dpt-to-arr great-circle distance is used.

        3. Files the PIREP with the supplied `landing_rate`, `fuel_used`,
        `flight_time`, and any of the optional `zfw` / `block_fuel` /
        `block_time` / `level` / `route` fields.

        4. Appends any `comments` as pilot comments on the PIREP.

        5. Calls phpVMS's `submit()` which fires the `PirepFiled` event, handles
        diversions, and applies rank-based auto-approval.


        `flight_time` is in **decimal hours** here (the server multiplies by 60
        to store minutes). Either `uuid` or `tracking_id` may carry the PIREP
        ID.
      operationId: completeFlight
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompleteFlightRequest'
      responses:
        '200':
          description: PIREP filed and submitted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompleteFlightResponse'
        '400':
          $ref: '#/components/responses/MissingTrackingId'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/PirepNotFound'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    CompleteFlightRequest:
      type: object
      properties:
        uuid:
          type: string
          format: uuid
          description: PIREP ID. Either this or `tracking_id` is required.
        tracking_id:
          type: string
          format: uuid
        flight_data:
          type: array
          items:
            $ref: '#/components/schemas/FlightLogEntry'
          description: Log entries saved as ACARS LOG rows.
        flight_log:
          type: array
          items:
            $ref: '#/components/schemas/FlightLogEntry'
          description: Legacy field name — used only when `flight_data` is empty.
        landing_rate:
          type: number
          format: float
          description: Touchdown rate (feet per minute, negative).
        fuel_used:
          type: number
          format: float
          description: Total fuel burn, pounds.
        flight_time:
          type: number
          format: float
          description: Total flight time in decimal hours. Server stores as minutes.
        zfw:
          type: number
          format: float
          description: Zero-fuel weight in lbs.
        block_fuel:
          type: number
          format: float
          description: Block fuel in lbs.
        block_time:
          type: number
          format: float
          description: Block time in decimal hours.
        level:
          type: number
          format: float
          description: Cruise flight level (e.g. 360).
        route:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: >-
            Route. If sent as an array, the server joins on spaces. Omit to
            preserve the route prefiled at `/flights/start`.
        comments:
          type: array
          items:
            $ref: '#/components/schemas/FlightComment'
          description: Pilot comments to attach to the filed PIREP.
    CompleteFlightResponse:
      type: object
      required:
        - pirep_id
        - flight_number
        - route
        - aircraft
        - aircraft_icao
        - registration
        - airline
        - airline_icao
      properties:
        pirep_id:
          type: string
          format: uuid
        flight_number:
          type: string
          description: Airline code + flight number (e.g. `QFA1`).
          example: QFA1
        route:
          type: string
          description: '`<dpt-icao> - <arr-icao>` summary.'
          example: YSSY - YMML
        aircraft:
          type: string
          description: Aircraft name (falls back to registration if unnamed).
        aircraft_icao:
          type: string
        registration:
          type: string
        airline:
          type: string
        airline_icao:
          type: string
    FlightLogEntry:
      type: object
      description: >-
        Free-form log line saved verbatim as an ACARS LOG row. The reference
        implementation does not parse `event` — clients are free to include
        whatever structure they want.
      properties:
        event:
          type: string
          description: Log message body.
        timestamp:
          type: string
          format: date-time
          description: ISO 8601 timestamp. Defaults to receive-time if omitted.
    FlightComment:
      oneOf:
        - type: string
        - type: object
          properties:
            event:
              type: string
            text:
              type: string
            comment:
              type: string
      description: >-
        Pilot comment to attach to the PIREP. The server picks the first
        non-empty value from `event`, `text`, `comment` (in that order) if an
        object is supplied.
    Error:
      type: object
      properties:
        error:
          type: string
        success:
          type: boolean
        message:
          type: string
  responses:
    MissingTrackingId:
      description: Required `uuid` / `tracking_id` was not supplied.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: tracking_id is required
    Unauthorized:
      description: Missing or invalid Bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Invalid Token
    PirepNotFound:
      description: No PIREP exists for the supplied tracking ID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: PIREP not found
    ServerError:
      description: >-
        Unhandled server error. The `error` field carries the message; check
        server logs for the trace.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        The pilot's API key, obtained via `POST /pilot/login` or your OAuth
        flow. Send as `Authorization: Bearer <api_key>` on every authenticated
        request.

````