An upper endoscopy allows a doctor to examine the upper part of the gastrointestinal (GI) tract. The upper part of the gastrointestinal tract is made up of the following parts of the body:
Esophagus, which is the muscular tube that connects the throat to the stomach
Duodenum, which is the top of the small intestine
An upper endoscopy is also called an upper GI endoscopy or esophagogastroduodenoscopy (EGD).
How does an upper endoscopy work?
To perform an upper endoscopy, the doctor uses a tool called an endoscope. An endoscope is a thin, flexible tube with a light and a tiny camera on the end. It is inserted into the mouth, down the throat, and into the esophagus. The doctor views the images on a screen to look for tumors or other health problems.
During an upper endoscopy, the doctor can remove tissue samples, including polyps. Polyps are noncancerous growths that could become cancerous over time. The doctor uses tools passed through a channel in the endoscope to remove tissue samples. Then, the samples are examined under a microscope.
Additionally, some endoscopes have technology known as narrow band imaging. This uses colored light to find precancerous conditions  in the esophagus lining.
Who does my upper endoscopy?
An upper endoscopy is done in a doctor's office, GI clinic, or hospital. Most often, a gastroenterologist performs the procedure. A gastroenterologist is a doctor who specializes in the GI tract. Many other specialists can perform an upper endoscopy as well.
Getting ready for an upper endoscopy
When you schedule the procedure, you will get detailed instructions on how to prepare. These may include instructions such as the following:
Not eating or drinking anything, including water, for up to 8 hours before. Your stomach and duodenum must be completely empty.
Not taking aspirin or other over-the-counter pain medications for 7 days before. These medicines can increase the risk of bleeding during the procedure.
Ask the doctor or nurse about these or any other restrictions when you schedule the procedure.
Additionally, check with your insurance provider in advance. Find out whether the cost of the procedure will be covered and whether you may need to pay part of it.
Once you arrive for your upper endoscopy, you will be asked to sign a consent form. It states that you understand the benefits and risks and agree to undergo the test.
During the procedure
Before the procedure begins, you will need to undress and put on a hospital gown. If you wear dentures, you may be asked to remove them.
You may be given anesthesia  and a sedative through an intravenous (IV) needle in your arm. Anesthesia is medicine that blocks the awareness of pain. A sedative is medicine that relaxes you. These medications help reduce discomfort during the procedure. You may feel a slight sting when the IV needle is inserted.
A doctor or nurse may spray your throat with a local anesthetic to numb it. Or, you may receive a liquid anesthetic to gargle. This helps prevent gagging. Also, the doctor may insert a mouthpiece to hold your mouth open during the procedure.
You will lie on your left side or your back on an exam table. As the doctor slowly inserts the endoscope, you will feel pressure through your esophagus. The endoscope inflates your stomach by blowing air into it. This gives the doctor a better view of the stomach lining.
You will be able to breathe on your own throughout the exam. Taking slow, deep breaths through your nose will help you relax. Many patients fall asleep.
An upper endoscopy usually takes 20 to 30 minutes to complete.
When the procedure is over, the doctor will gently remove the endoscope. Then, you will go to a recovery room.
Your throat may feel sore. And you may have bloating or cramping because of the air blown into your stomach. You may also feel some discomfort from lying still for a long time.
After the procedure
Afterward, you will stay for up to 2 hours while the effects of the anesthesia and sedative wear off. You will also need a ride home. Anesthesia and sedatives can temporarily impair your reaction speed and judgment.
The doctor or nurse will tell you how soon you can eat and drink. Typically, you can return to your usual activities the next day.
If you have a sore throat, you can gargle with salt water to relieve the discomfort.
Problems after an upper endoscopy are uncommon. However, call your doctor immediately if you experience any of these symptoms:
Severe throat, chest, or abdominal pain
Shortness of breath
Questions to ask your doctor
Before having an upper endoscopy, consider asking the following questions:
Who will perform the upper endoscopy? Will anyone else be in the room?
What will happen during the upper endoscopy?
How long will the procedure take?
Will it be painful?
Will I be given any type of anesthesia or sedation?
What are the risks and benefits of having an upper endoscopy?
How accurately does an upper endoscopy find cancer?
When will I learn the results? How will they be communicated to me?
Who will explain the results to me?
What other tests will I need if the upper endoscopy finds evidence of cancer?
American Society for Gastrointestinal Endoscopy: Upper Endoscopy Educational Video 
Society of American Gastrointestinal and Endoscopic Surgeons: Upper Endoscopy