It is not known when Shangguan Yi was born. His family was initially from what would eventually become Shan Prefecture , but as his father Shangguan Hong served as the deputy director of Emperor Yang of Sui's palace at the secondary capital Jiangdu , the Shangguan household relocated to Jiangdu and settled there.
Late in Emperor Yang's ''Daye'' era , Shangguan Hong was killed by the general Chen Leng . Shangguan Yi was still young at the time, and he escaped death by going into hiding. Thereafter, he became a Buddhist monk and spent much time on studying the sutras. He also studied the , and was said to be literarily talented.
During Emperor Taizong's reign
Early in the reign of succeeding Tang Dynasty's second emperor , Yang Gongren was serving as the acting commandant at Yang Prefecture , when Yang became impressed with Shangguan's talents and recommended him for the imperial examination. Emperor Taizong also heard of Shangguan's talent, and made him an imperial scholar and later an official at the archival bureau. As Emperor Taizong himself liked to write, he often had Shangguan review his drafts and also write responses to them; he also often invited Shangguan to imperial feasts. Shangguan also participated in the writing of the ''Book of Jin'', the official history of the Jin Dynasty , a project led by the Fang Xuanling. After the project was complete, he became an imperial historian and was awarded with linen.
During Emperor Gaozong's reign
After Emperor Taizong's death in 649, Emperor Taizong's son became emperor . Sometime thereafter, he made Shangguan Yi the deputy director of the archival bureau. In 662, he promoted Shangguan to be ''Xi Tai Shilang'' , the deputy head of the legislative bureau of government , along with the honorific title ''Yinqing Guanglu Daifu'' . He also gave Shangguan the designation ''Tong Dong Xi Tai Sanpin'' , making him a chancellor ''de facto''. It was said that Shangguan was by now particularly known for his poetry, particularly a style featuring five characters per line; his poetry was said to be decorated and delicate -- a style that was then often imitated and became known as the Shangguan Style. It was said that Shangguan was arrogant because of his talent, and became the object of much jealousy.
By 664, Emperor Gaozong was said to be deeply fearful and resentful of his powerful second wife , as she interfered with his decisions. After the eunuch Wang Fusheng reported to Emperor Gaozong that Empress Wu had, against strict regulations, engaged the Taoist monk Guo Xinzhen to engage in sorcery, Emperor Gaozong was angry, and he summoned Shangguan to ask for advice on what to do. Shangguan suggested, "The empress has no control of herself, and the entire empire is dissatisfied with her. Please depose her." Emperor Gaozong agreed and had Shangguan draft an edict deposing her. However, because among Emperor Gaozong's attendants were her allies, she found out, and she immediately appeared before him to defend herself. As Emperor Gaozong was caught red-handed with the draft edict in his hand, Emperor Gaozong was ashamed, and he reconciled with her. He further blamed Shangguan for the idea, to divert Empress Wu's displeasure. As Shangguan had served on the staff of Emperor Gaozong's first crown prince Li Zhong (who was not born of Empress Wu and who was displaced by Empress Wu's son Li Hong in 656 while Li Zhong was the Prince of Chen, and later both Shangguan and Wang served on Li Zhong's staff while Li Zhong was crown prince, Empress Wu had her ally Xu Jingzong accuse Shangguan, Wang, and Li Zhong of plotting to kill Emperor Gaozong. Around the new year 665, Shangguan and Wang were both arrested and executed. Also kllled was Shangguan's son Shangguan Tingzhi . Li Zhong was thereafter forced to commit suicide. Shangguan's assets were seized, and his family were taken as servants. A number of officials close to Shangguan, including fellow chancellor Liu Xiangdao, were demoted.
Shangguan Tingzhi's daughter Shangguan Wan'er, who was also literarily talented, became a palace servant. Empress Wu favored her talent and made her a secretary. After Empress Wu had seized the throne herself but then was overthrown by her son in 705, Emperor Zhongzong took Shangguan Wan'er as a concubine. She became powerful, as Emperor Zhongzong often had her draft his edicts. For this reason, Emperor Zhongzong posthumously awarded both Shangguan Yi and Shangguan Tingzhi a number of honors and reburied them with honor.