Introduction
Shunahshepa is a boy who was to be sacrificed at the sacrifice of King Ambarisha, and was saved by the sage Vishwamitra, who adopted him as his eldest son and named him Devarata.
This article primarily follows the Valmiki Ramayana. Where a well-known detail comes from a later retelling or tradition, the article identifies it.
The story
King Ambarisha's sacrificial animal escaped, and he needed a human substitute. He bought Shunahshepa from his father. As he was about to be sacrificed, Shunahshepa prayed to the gods with a mantra taught by Vishwamitra, and was released.
Vishwamitra's son
Vishwamitra adopted him. This story is told in the Bala Kanda and in the Aitareya Brahmana.