When do I need a Form 6166, a letter of U.S. residency certification?

Form 6166 (U.S. Residency Certification Letter) is what you need when a foreign government requires you to show that you are a U.S. tax…