The Messenger of Allah ﷺ said, "When one of you rises from his bed and then returns to it, let him dust it off three times with the edge of his lower garment, for he does not know what came upon it after he left. When he lies down, let him say, 'In Your name, my Lord, I lay down my side, and by You I raise it. If You take my soul, have mercy on it, and if You release it, protect it with that by which You protect Your righteous servants.' And when he wakes up, let him say, 'Praise be to Allah who restored health to my body, returned my soul to me, and permitted me to remember Him.'"
أن رسول الله ﷺ قال: إذا قام أحدكم عن فراشه ثم رجع إليه فلينفضه بصنفة إزاره ثلاث مرات؛ فإنه لا يدري ما خلفه عليه بعد، فإذا اضطجع فليقل: باسمك ربي وضعت جنبي، وبك أرفعه، فإن أمسكت نفسي فارحمها، وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين، فإذا استيقظ فليقل: الحمد لله الذي عافاني في جسدي، ورد علي روحي، وأذن لي بذكره.
Tirmidhi (3401), Nasai in Amal al-Yawm wal-Layla (866), and Ibn Sunni (9) all narrated it through Sufyan bin Uyayna, from Ibn Ajlan, from Saeed Maqburi, from Abu Hurairah, and he mentioned it. The wording given is that of Tirmidhi, while Nasai and Ibn Sunni confined themselves to the supplication for waking up.Its chain is hasan because of Muhammad bin Ajlan, and the first part is found in the Sahihayn. Tirmidhi said, "A hasan hadith." Ibn Hajar said in Nataij Afkar (1/113), "This is a hasan hadith by this route with this wording, and the basis of its first part is sahih."