In October of 1914, the British Naval Intelligence (known as Room 40) recovered a copy of the German naval codebook from a drowned German sailor's body.
Room 40 also received a copy of the German diplomatic code, stolen from a German diplomat's luggage in the Near East.
By 1917, the British could decipher most of the German messages.
On January 16, 1917, British codebreakers intercepted an encrypted telegram message from German Foreign Secretary Arthur Zimmermann intended for the German ambassador to Mexico.
The telegram gave the ambassador a now-famous set of instructions: if the neutral United States entered the war on the side of the Allies, he was to approach Mexico’s president with an offer to forge a secret wartime alliance. The Germans would provide military and financial support for a Mexican attack on the United States, and in exchange, Mexico would be free to annex “lost territory in Texas, New Mexico, and Arizona.”
The British Room 40 decoded the Zimmermann Telegram and handed it over to the United States in late-February 1917. By March 1, its scandalous contents were splashed on the front pages of newspapers nationwide. Diplomatic relations between Germany and the United States had already been severed in early February when Germany resumed unrestricted submarine warfare and began preying on U.S. vessels in the Atlantic. While many Americans remained committed to isolationism, the Zimmerman cipher now served as fresh evidence of German aggression. Coupled with the submarine attacks, it finally turned the U.S. government in favor of entering the fray. On April 2, 1917, President Wilson abandoned his policy of neutrality and asked Congress to declare war against Germany and the Central Powers. Most historians agree that American involvement in World War 1 was inevitable but the March to war was no doubt accelerated by the notorious Zimmermann Telegram.