A fare basis code (also called a fare code or fare class) is an alphanumeric or alphabetic code that appears on your booking record and your ticket. It tells airline staff what contract applies to your ticket—such as what upgrades you’re eligible for, whether or not the ticket is refundable, how much mileage you’ll earn, and whether you can make changes to your itinerary.
There are different fare basis codes not only for different booking classes—business class is a different category than economy, for instance—but even within the same class (such as economy), there may be multiple fare codes with varying conditions for each specific fare.
Fare basis codes aren’t solely for airline staff, and knowing your booking class can tell you in advance whether it’s even worth asking about things like upgrades. Within the fare code, one or two letters can tell you what fare class you have.
While the letters can vary a bit by airline, an “F” nearly always means first class, while business class is often indicated with a J, C, or D. Economy class has a long potential list of letters associated with it, with Y, L, M, Q, T, B, and K being among the most common.
Many airlines have a list of the fare codes they use on their websites—a simple web search for “fare codes [airline name]” brings up the relevant results. You can also consult your booking confirmation email, which may even list the fare class in a more straightforward way—such as “Economy (Y).” Using that information, you can look into the fare rules or restrictions for that class to find out what options you have on your ticket.
Here's an example of American Airlines' fare chart, which details the amount of qualifying frequent flyer miles earned per fare code.