MyFlightbook Logbook Sync

Connect your MyFlightbook account to AeroCopilot via OAuth2 and import flights, aircraft, currency, and totals — read-only and rate-limited.

MyFlightbook Logbook Sync

AeroCopilot integrates with MyFlightbook over OAuth2 so you can import your existing logbook history without re-keying entries. The connection is strictly read-only against the live MyFlightbook site — AeroCopilot never modifies, deletes, or writes flights, aircraft, or properties back to your MFB account.

How the connection works

The integration uses the standard OAuth2 authorization-code flow.

  • Start the connection at /api/integrations/myflightbook/authorize. You will be redirected to MyFlightbook's consent screen.
  • Approve the requested scopes, all of which are read-only: currency, totals, readflight, readaircraft, visited, namedqueries.
  • Return to AeroCopilot via the callback at /api/integrations/myflightbook/callback, where the access and refresh tokens are exchanged and stored.
  • Disconnect at any time via /api/integrations/myflightbook/disconnect, which deletes your stored tokens.

Tokens are encrypted at rest using AES-256-GCM in the IntegrationToken table. When the access token expires, AeroCopilot automatically refreshes it using the stored refresh token before the next API call. If no refresh token is available, you will be prompted to reconnect.

What gets synced

A full sync orchestrates four sequential calls against the MyFlightbook JSON API. Calls are spaced at least 500 ms apart to respect MyFlightbook's server load.

Flights (FlightsWithQueryAndOffset)

Flights are paged in batches of 50 and inserted into your AeroCopilot logbook. Field mapping:

  • Date → entry date
  • TailNumDisplay → aircraft N-number
  • ModelDisplay → aircraft type
  • Route → first token becomes departure, last token becomes destination (truncated to 4 characters)
  • TotalFlightTime, PIC, SIC, CrossCountry, Nighttime, IMC, SimulatedIFR, Dual, CFI → corresponding decimal-hour columns
  • FullStopLandings minus NightLandingsdayLandings (because MFB reports total full-stop landings, not day-only)
  • NightLandings → night landing count
  • Approaches → integer count
  • fHoldingProcedures → 1 if true, else 0
  • Comment → remarks

Duplicate detection runs on the composite key date:departure:destination. Flights matching an existing entry are skipped, not overwritten. Each sync writes a LogbookImport record (processingcompleted or failed) capturing imported and skipped counts.

Aircraft (AircraftForUser)

Returns the list of aircraft registered in your MFB account with tail number and model description. The list is surfaced in the UI for review; the integration does not yet auto-create UserAircraft rows because that requires a registration lookup.

Currency (GetCurrencyForUser)

MyFlightbook tracks a wide range of currency attributes. AeroCopilot currently maps two into your CurrencyRecord table:

  • Flight ReviewBFR
  • Instrument Proficiency CheckIPC

For each mapped item, AeroCopilot updates the existing record's source to myflightbook and stores the MFB value, status, and any discrepancy in the notes field. Other MFB currency attributes are returned for display but not persisted.

Totals (TotalsForUser)

Returns flight-hour summaries (description, value, sub-description) for display only. Totals are not persisted to your AeroCopilot account.

Safety guarantees

The MFB client enforces a hard whitelist of read methods (AircraftForUser, FlightsWithQueryAndOffset, GetCurrencyForUser, TotalsForUser, VisitedAirports, and similar). Any attempt to call a write method (AddAircraftForUser, CommitFlightWithOptions, DeleteLogbookEntry, etc.) against the live myflightbook.com host throws BLOCKED: and aborts. This guard exists because aircraft records are shared between pilots in MFB — an accidental write could affect other users' data.

Required configuration

To enable the integration, the following environment variables must be set on the server:

  • MFB_CLIENT_ID
  • MFB_CLIENT_SECRET
  • MFB_BASE_URL (defaults to https://myflightbook.com)
  • API Library Overview
  • Logbook
  • Currency Tracking