Endoscopy is a medical procedure used to visually examine the inside of the body using an endoscope, a flexible tube with a light and camera attached to it. It is commonly used to diagnose and treat conditions affecting the gastrointestinal (GI) tract, such as ulcers, inflammation, bleeding, tumors, and other abnormalities.