The Messenger of Allah ﷺ used to say when he lay down to sleep, "Praise be to Allah who has sufficed me, sheltered me, fed me, and given me drink. Praise be to Him who has favored me and shown abundant grace, and who has given me generously. Praise be to Allah in every state. O Allah, Lord of all things and their Sovereign, God of all things, I seek refuge in You from the Fire."
حدثنا علي بن مسلم حدثنا عبد الصمد قال حدثني أبي حدثنا حسين عن ابن بريدة
أن رسول الله ﷺ كان يقول إذا أخذ مضجعه الحمد لله الذي كفاني وآواني وأطعمني وسقاني والذي من علي فأفضل والذي أعطاني فأجزل الحمد لله على كل حال اللهم رب كل شيء ومليكه وإله كل شيء أعوذ بك من النار
[Its chain of transmission is hasan] Ahmad narrated it, 2/117, from Abdul-Samad through the same route. Nasai also narrated it in Kubra, no. 10634, and in Amal al-Yawm wal-Layla, no. 798. Ibn Hibban graded it sahih, no. 2357, and so did Hakim, 1/514, with Dhahabi concurring. It has a corroborating narration in Hakim, 1/545, 546, and both of them graded it sahih.