Upper gastrointestinal endoscopy is a procedure that allows a doctor to examine the esophagus, stomach, and duodenum. During the procedure, a thin, flexible tube with a camera and light is inserted through the mouth and into the upper GI tract. Endoscopy allows doctors to view the inside of the upper GI tract and detect any abnormalities, such as ulcers or tumors.