All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and messenger.
It is permissible to sleep in an outdoor terrace if it has a wall that provides protection for the sleeping person from falling down. There is a warning in the Sunnah against sleeping on top of a house that has no walls that prevent from falling. 'Ali ibn Shaybaan narrated that the Prophet said: “Whoever sleeps on the roof of a house that has no walls, then there is no obligation towards him by anyone (i.e. nobody is required to do anything due to his death).”
This is because if a person sleeps in that manner, he might turn over while sleeping, and thus fall down and die, in which case, no legal action is to be taken for his death. Also, if he dies in that manner, he dies without being prepared for death, as per the Fiqh Encyclopedia.
Also, if this terrace is open in a way that allows others to see the person, then one should cover one's ‘Awrah (parts of the body that must be covered in Sharee'ah) during one's sleep, as the Prophet said: “Cover your ‘Awrah except from your wife or what your right hand possesses.” [Ahmad, Abu Daawood, at-Tirmithi and Ibn Maajah - Al-Albaani and Al-Arnaa’oot graded it as Hasan (good)]
Allaah Knows best.