What Is an Endoscopy and When Should You Get One? An endoscopy is a medical procedure used to examine the inside of a hollow organ or cavity. Doctors can use it to diagnose and treat certain conditions, such as ulcers, cancers, and obstructions. Endoscopy requires a specially trained doctor and high-tech equipment. Endoscopy is performed in two ways: through the mouth or the rectum (the large intestine).