Whenever the Messenger of Allah ﷺ wished to sleep, he would rest his head on his right hand and say, "Allah, protect me from Your punishment on the Day You gather Your servants."Abu Ishaq said, the other narrator said, "on the Day You resurrect Your servants."
حدثنا محمد بن جعفر قال حدثنا شعبة عن أبي إسحاق عن أبي عبيدة ورجل آخر
كان رسول الله ﷺ إذا أراد أن ينام توسد يمينه ويقول اللهم قني عذابك يوم تجمع عبادك قال فقال أبو إسحاق وقال الآخر يوم تبعث عبادك
Its isnad is sahih through the route of Ubayda, and daif through the route of the unknown man. The hadith was narrated by Abu Dawud, 4/310, no. 5045, in the Book of Manners, chapter on what one says upon sleeping, and by Tirmidhi, 5/471, no. 3398, who said, "Hasan gharib."