When the Messenger of Allah ﷺ would lie down at night, he would say, "In the name of Allah I lay down my side. Allah, forgive me my sin, drive away my devil, release my pledge, and place me in the highest assembly."
حدثنا جعفر بن مسافر التنيسي حدثنا يحيى بن حسان حدثنا يحيى بن حمزة عن ثور عن خالد بن معدان
أن رسول الله ﷺ كان إذا أخذ مضجعه من الليل قال بسم الله وضعت جنبي اللهم اغفر لي ذنبي وأخسئ شيطاني وفك رهاني واجعلني في الندي الأعلى
[Its chain of transmission is sahih] Tabarani reported it: 22/298, no. 779, from the hadith of Yahya bin Hamza, with this wording, and Hakim graded it sahih: 1/540, and Dhahabi agreed with him. Thawr is Ibn Yazid.