Hadithcore
Mishkat al-Masabih, 2400, 2401

Hudhaifa said that when the Prophet (ﷺ) wanted to go to sleep he placed his hand under his head and said, "O God, guard me from your punishment on the day when You gatherest Your servants," or "raisest up Your servants." Tirmidhi transmitted it, and Ahmad gave al-Bara’ as his authority.

وَعَنْ حُذَيْفَةَ أَنَّ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ كَانَ إِذَا أَرَادَ أَنْ يَنَامَ وَضَعَ يَدَهُ تَحْتَ رَأْسِهِ ثُمَّ قَالَ: «اللَّهُمَّ قِنِي عَذَابَكَ يَوْمَ تَجْمَعُ عِبَادَكَ أَوْ تَبْعَثُ عِبَادَكَ» . رَوَاهُ التِّرْمِذِيّ وَرَوَاهُ أَحْمد عَن الْبَراء

References1 variant
In-Book Reference
Book 9, Hadith 171