An antigen is a macromolecule that is recognized by antibodies or immune cells and can trigger an immune response. Usually, an antigen is a protein or a polysaccharide, but it can be any type of molecule, even small molecules if coupled to a large carrier. Antigens are presented by a cell to its environment via a histocompatibility molecule. Depending on the antigen presented and the histocompatibility molecule used, several types of immune cells can leap into action.
Exogenous antigens are antigens that have entered the body, e.g., by inhalation, ingestion, or injection. These antigens are taken up by endocytosis by the cell, and degraded into fragments. The fragments are then presented by class II histocompatibility molecules and attract phagocytic cells like macrophages and dendritic cells, as well as B lymphocytes (also called B cells) which can produce antibodies against this specific antigen.
Endogenous antigens are antigens that have been generated within the cell, e.g., by a virus, and are degraded into fragments. The fragments are then presented by class I histocompatibility molecules and attract CD8+ T cells, most of which are cytotoxic and kill the infected cell, usually before any viruses are released from the infected cell.
Cells display degraded proteins of all kinds this way, no matter if they are from a virus or just normal proteins of the cell. In order to keep the cytotoxic cells from killing cells just for presenting normal proteins, they run through a test cycle just after their production. Only the T cells that do not react to normal body protein fragments are allowed to enter the bloodstream.