openapi: 3.0.3

info:
  title: Shipment Tracking API
  version: 1.0.0
  description: |
    Retrieve real-time shipment tracking information from Jet Delivery.

    This endpoint returns shipment status, event history, requested and actual pickup/delivery times,
    estimated arrival information when available, and driver GPS location when permitted.

    ## Authentication behavior
    Tracking can be used publicly for valid shipment numbers. Supplying a valid API key may unlock
    additional account-authorized detail such as more precise geolocation.

    ## Error behavior
    This legacy endpoint often returns HTTP 200 with an `error` object in the response body for validation
    or lookup failures. Rate limiting returns HTTP 429.

servers:
  - url: https://www.jetdelivery.com

tags:
  - name: Tracking
    description: Real-time shipment tracking and event history.

paths:
  /api/v1/utilities/track/:
    get:
      tags:
        - Tracking
      summary: Track a shipment
      description: |
        Returns shipment tracking details for a Jet Delivery control number or tracking link lookup.

        Use `idx` for the standard tracking/control number lookup.

        You may also use:
        - `ref=link-idx` to resolve a public tracking link index
        - `ref=link-ref` to resolve a customer reference / PO / BOL style lookup

        When a valid API key is provided, the response may include additional account-authorized details
        such as more precise geolocation.
      operationId: getTracking
      security:
        - {}
        - QueryApiKey: []

      parameters:
        - name: idx
          in: query
          required: false
          description: |
            Shipment control number / tracking number.

            This is the primary lookup input for standard tracking requests.
          schema:
            type: string
            maxLength: 20
          example: "3768068"

        - name: ref
          in: query
          required: false
          description: |
            Optional lookup mode.

            - `link-idx`: treat `idx` as a public tracking-link index that resolves to a control number
            - `link-ref`: treat `idx` as a customer reference / PO / BOL style lookup
          schema:
            type: string
            enum:
              - link-idx
              - link-ref
          example: link-idx

        - name: matchtype
          in: query
          required: false
          description: |
            Matching mode used primarily with `ref=link-ref`.

            - `exact`: exact match against supported reference fields
            - omitted: partial/contains match behavior
          schema:
            type: string
            enum:
              - exact
          example: exact

        - name: key
          in: query
          required: false
          description: Optional API key. If valid, the response may include additional account-authorized detail.
          schema:
            type: string

      responses:
        '200':
          description: |
            Tracking response returned.

            Note: Validation or lookup failures are returned using a structured `error` object. 
            In many cases the HTTP status will still be 200 so the response body always contains a clear, human-readable error message.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackEnvelope'
              examples:
                delivered:
                  summary: Delivered shipment
                  value:
                    error: null
                    data:
                      track_no: "3768068"
                      status_code: "15"
                      status_description: "Delivered"
                      status_datetime: "2026-03-05T09:34:00-08:00"
                      active_jobs_on_driver: 1
                      driver_no: "287"
                      number_of_customers: 1
                      geolocation: null
                      geolocation_secs_offset: null
                      origin_geolocation: "33.74203040,-117.16370450"
                      origin_req_arrive_datetime: "2026-03-05T08:30:00-08:00"
                      origin_req_depart_datetime: null
                      origin_eta_arrive_datetime: null
                      origin_eta_minutes_until_pickup: null
                      origin_act_arrive_datetime: "2026-03-05T08:52:00-08:00"
                      origin_act_depart_datetime: "2026-03-05T08:52:00-08:00"
                      origin_departed_minutes_ago: 4383
                      origin_local_time: "2026-03-08T10:54:32-07:00"
                      ready_at_localtime: "2026-03-05T08:30:00-08:00"
                      origin_tz: "PST"
                      destination_geolocation: "33.86988080,-117.24532350"
                      destination_req_arrive_datetime: null
                      destination_req_depart_datetime: "2026-03-05T11:30:00-08:00"
                      destination_eta_arrive_datetime: null
                      destination_eta_minutes_until_deliver: null
                      destination_act_arrive_datetime: "2026-03-05T09:34:00-08:00"
                      destination_act_depart_datetime: "2026-03-05T09:34:00-08:00"
                      destination_local_time: "2026-03-08T10:54:32-07:00"
                      destination_tz: "PST"
                      departure_airport_geolocation: null
                      scheduled_flight_departure: null
                      scheduled_flight_arrival: null
                      actual_flight_departure: null
                      actual_flight_arrival: null
                      departure_airport_tz: null
                      arrival_airport_geolocation: null
                      arrival_airport_tz: null
                      reference: "M-F MORNING ROUTE"
                      geolocation_is_actual: "true"
                      signature: "Dawna Hartman"
                      more_details_uri: "/smartship/tools/order/?idx=3768068"
                      events:
                        - datetime: "2026-03-04T15:00:00-08:00"
                          description: "Order scheduled via telephone"
                        - datetime: "2026-03-04T15:01:07-08:00"
                          description: "Driver dispatched to Romoland, CA 92585"
                        - datetime: "2026-03-05T08:52:00-08:00"
                          description: "Driver departed from Romoland, CA 92585"
                        - datetime: "2026-03-05T09:34:00-08:00"
                          description: "Drop-off completed in Moreno Valley, CA 92551"

                invalidTracking:
                  summary: Invalid tracking number returned as application error
                  value:
                    error:
                      message: "Invalid tracking number"
                      details: null
                    data: null

                unableToLocate:
                  summary: Unable to locate shipment
                  value:
                    error:
                      message: "Unable to locate"
                      details: null
                    data: null

        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackEnvelope'
              example:
                error:
                  message: "Rate limit exceeded. Try again later."
                  details: null
                data: null

components:
  securitySchemes:
    QueryApiKey:
      type: apiKey
      in: query
      name: key
      description: Optional API key supplied via querystring.

  schemas:
    TrackEnvelope:
      type: object
      properties:
        error:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/ErrorObject'
        data:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/TrackData'
      required:
        - error
        - data

    ErrorObject:
      type: object
      description: |
        Error envelope for application-level failures.

        Note: the exact serialized shape of Jet Delivery's legacy `Error` object should be verified
        against live responses. This schema reflects the current documented assumption.
      properties:
        message:
          type: string
          example: Invalid tracking number
        details:
          nullable: true
          description: Optional structured detail payload when available.
      required:
        - message

    TrackData:
      type: object
      properties:
        track_no:
          type: string
          description: Shipment control number / tracking number.
          example: "3768068"

        status_code:
          type: string
          description: Internal tracking status code.
          example: "15"

        status_description:
          type: string
          description: Human-readable shipment status.
          example: Delivered

        status_datetime:
          type: string
          format: date-time
          nullable: true
          description: Timestamp for the current status.
          example: "2026-03-05T09:34:00-08:00"

        active_jobs_on_driver:
          type: integer
          description: Number of active jobs currently associated with the assigned driver.
          example: 1

        driver_no:
          type: string
          nullable: true
          description: Assigned driver number when available.
          example: "287"

        number_of_customers:
          type: integer
          description: Number of distinct customers represented in the driver's current active work.
          example: 1

        geolocation:
          type: string
          nullable: true
          description: Current driver / shipment geolocation as `lat,lng` when available and allowed.
          example: "33.812345,-117.234567"

        geolocation_secs_offset:
          type: string
          nullable: true
          description: Age of the returned geolocation in seconds.
          example: "42.6"

        origin_geolocation:
          type: string
          nullable: true
          description: Pickup-side geolocation shown to the caller.
          example: "33.74203040,-117.16370450"

        origin_req_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Requested pickup arrival time.
          example: "2026-03-05T08:30:00-08:00"

        origin_req_depart_datetime:
          type: string
          format: date-time
          nullable: true
          description: Requested pickup departure time.
          example: "2026-03-05T08:45:00-08:00"

        origin_eta_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Estimated pickup arrival time when available.
          example: "2026-03-05T08:40:00-08:00"

        origin_eta_minutes_until_pickup:
          type: number
          nullable: true
          description: Minutes until estimated pickup arrival.
          example: 12

        origin_act_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Actual pickup arrival time.
          example: "2026-03-05T08:52:00-08:00"

        origin_act_depart_datetime:
          type: string
          format: date-time
          nullable: true
          description: Actual pickup departure time.
          example: "2026-03-05T08:52:00-08:00"

        origin_departed_minutes_ago:
          type: number
          nullable: true
          description: Number of minutes since the shipment departed the origin.
          example: 4383

        origin_local_time:
          type: string
          format: date-time
          nullable: true
          description: Current local time at the origin.
          example: "2026-03-08T10:54:32-07:00"

        ready_at_localtime:
          type: string
          format: date-time
          nullable: true
          description: Shipment ready time in origin local time.
          example: "2026-03-05T08:30:00-08:00"

        origin_tz:
          type: string
          nullable: true
          description: Origin timezone code.
          example: PST

        destination_geolocation:
          type: string
          nullable: true
          description: Delivery-side geolocation shown to the caller.
          example: "33.86988080,-117.24532350"

        destination_req_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Requested delivery arrival time.
          example: "2026-03-05T11:00:00-08:00"

        destination_req_depart_datetime:
          type: string
          format: date-time
          nullable: true
          description: Requested delivery departure time.
          example: "2026-03-05T11:30:00-08:00"

        destination_eta_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Estimated delivery arrival time when available.
          example: "2026-03-05T09:28:00-08:00"

        destination_eta_minutes_until_deliver:
          type: number
          nullable: true
          description: Minutes until estimated delivery arrival.
          example: 18

        destination_act_arrive_datetime:
          type: string
          format: date-time
          nullable: true
          description: Actual delivery arrival time.
          example: "2026-03-05T09:34:00-08:00"

        destination_act_depart_datetime:
          type: string
          format: date-time
          nullable: true
          description: Actual delivery departure / completion time.
          example: "2026-03-05T09:34:00-08:00"

        destination_local_time:
          type: string
          format: date-time
          nullable: true
          description: Current local time at the destination.
          example: "2026-03-08T10:54:32-07:00"

        destination_tz:
          type: string
          nullable: true
          description: Destination timezone code.
          example: PST

        departure_airport_geolocation:
          type: string
          nullable: true
          description: Airport departure geolocation for flight-related shipments.
          example: "33.9416,-118.4085"

        scheduled_flight_departure:
          type: string
          format: date-time
          nullable: true
          description: Scheduled flight departure timestamp for flight-related shipments.

        scheduled_flight_arrival:
          type: string
          format: date-time
          nullable: true
          description: Scheduled flight arrival timestamp for flight-related shipments.

        actual_flight_departure:
          type: string
          format: date-time
          nullable: true
          description: Actual flight departure timestamp for flight-related shipments.

        actual_flight_arrival:
          type: string
          format: date-time
          nullable: true
          description: Actual flight arrival timestamp for flight-related shipments.

        departure_airport_tz:
          type: string
          nullable: true
          description: Departure airport timezone code.

        arrival_airport_geolocation:
          type: string
          nullable: true
          description: Arrival airport geolocation for flight-related shipments.

        arrival_airport_tz:
          type: string
          nullable: true
          description: Arrival airport timezone code.

        reference:
          type: string
          nullable: true
          description: Customer reference or route reference associated with the shipment.
          example: M-F MORNING ROUTE

        geolocation_is_actual:
          type: string
          description: |
            Indicates whether the geolocation shown is precise/account-authorized (`true`)
            or reduced/public/centroid-style (`false`).
          enum:
            - "true"
            - "false"
          example: "true"

        signature:
          type: string
          nullable: true
          description: Delivery signature or signature-equivalent text when available.
          example: Dawna Hartman

        more_details_uri:
          type: string
          nullable: true
          description: Relative URI for additional shipment detail or proof documents.
          example: /smartship/tools/order/?idx=3768068

        events:
          type: array
          description: Chronological shipment event history.
          items:
            $ref: '#/components/schemas/TrackEvent'

      required:
        - track_no
        - status_code
        - status_description
        - active_jobs_on_driver
        - number_of_customers
        - geolocation_is_actual
        - events

    TrackEvent:
      type: object
      properties:
        datetime:
          type: string
          format: date-time
          nullable: true
          description: Event timestamp.
          example: "2026-03-05T09:34:00-08:00"
        description:
          type: string
          description: Human-readable event description.
          example: Drop-off completed in Moreno Valley, CA 92551
      required:
        - description