During an ERCP (endoscopic retrograde cholangiopancreatography), a flexible, thin, lighted tube called an endoscope is inserted through the mouth to allow the physician to access the bile and pancreatic ducts. An ERCP is typically used to diagnose and treat conditions of the bile ducts including gallstones and inflammatory strictures (scars).