When the Prophet ﷺ would sleep, he would put his hand under his head then say: “O Allah, safeguard me from Your Punishment the Day You gather [Your slaves] (Allāhumma qinī ʿadhābaka yawma tajmaʿu [ʿibādak])” or “you resurrect your slaves (tabʿathu ʿibādak).”
أَنَّ النَّبِيَّ ﷺ كَانَ إِذَا أَرَادَ أَنْ يَنَامَ وَضَعَ يَدَهُ تَحْتَ رَأْسِهِ ثُمَّ قَالَ اللَّهُمَّ قِنِي عَذَابَكَ يَوْمَ تَجْمَعُ عِبَادَكَ أَوْ تَبْعَثُ عِبَادَكَ قَالَ هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ