Sansom first arrived in Japan in 1904 and was attached to the British legation in Tokyo to learn the Japanese language. While he was working as private secretary to Sir Claude Maxwell MacDonald the legation gained higher status by becoming an embassy, and Sansom was present during the negotiations for the renewal of the Anglo-Japanese Alliance in 1905. He remained in Japan for most of his diplomatic career, serving in consulates around Japan, where he also acquired proficiency in Japanese dialects.