When the Messenger of Allah ﷺ wanted to sleep, he would rest his head on his right hand and say, "O Allah, protect me from Your punishment on the Day You gather Your servants."In another wording, "on the Day You resurrect Your servants."
كان رسول الله ﷺ إذا أراد أن ينام، توسد يمينه، ويقول: اللهم قني عذابك يوم تجمع عبادك. وفي لفظ يوم تبعث عبادك
Ahmad (18422) and Nasai in Amal al-Yawm wal-Layla (754) both narrated it from the hadith of Muhammad bin Jafar, who said, Shuba narrated to us, from Abu Ishaq, from Abu Ubayda and another man, from Bara bin Azib, and he related it.As for this other man, Tirmidhi said, "Perhaps he is Abdullah bin Yazid." Ilal al-Kabir (2/908).I say, it is as he said, for Ahmad (18660, 18672), Tirmidhi in Shamail (254), and Nasai in Amal al-Yawm wal-Layla (755) all narrated it through various routes from Israil, from Abu Ishaq, from Abdullah bin Yazid Ansari, from Bara, and he related it. Its chain of transmission is sahih. There has been extensive disagreement about the chain of transmission back to Abu Ishaq, but what I have mentioned is the most sahih of them.Similar in meaning is what was narrated from Hafsa, wife of the Prophet ﷺ, that the Messenger of Allah ﷺ, when he intended to lie down to sleep, would place his right hand under his cheek and then say, "O Allah, protect me from Your punishment on the day You resurrect Your servants," three times.Abu Dawud (5045) and Nasai in Amal al-Yawm wal-Layla (762) both narrated it through the route of Aban (that is, Ibn Yazid Attar), who said, Asim bin Abu Najud narrated to us, from Mabad bin Khalid, from Sawa Khuzai, from Hafsa, and he related it.Sawa Khuzai was not deemed reliable by anyone, except that Ibn Hibban mentioned him among his trustworthy narrators. For this reason Ibn Hajar said, "Acceptable," meaning when corroborated, but I have found no one to corroborate him. As for Asim bin Abu Najud, he is truthful, but there is weakness in his memory, and there has been disagreement regarding his chain. Some narrated from him, from Mabad, from Sawa. Others narrated from him, from Musayab, from Sawa. And others narrated from him, from Sawa directly. Perhaps this disagreement originates from Asim himself, for he was not a precise and reliable memorizer of hadith.