Abdullah bin Umar reported,

He instructed a man that when he lay down to sleep, he should say, "O Allah, You created my soul and You take it. To You belong its death and its life. If You keep it alive, then preserve it, and if You cause it to die, then forgive it. O Allah, I ask You for well-being."A man asked him, "Did you hear this from Umar?"He replied, "From one better than Umar, from the Messenger of Allah ﷺ."Ibn Nafi said in his narration from Abdullah bin Harith, and he did not mention "I heard."

Muslim 6888

Sahih

حدثنا عقبة بن مكرم العمي وأبو بكر بن نافع قالا حدثنا غندر حدثنا شعبة عن خالد قال سمعت عبد الله بن الحارث يحدث

عن عبد الله بن عمر

أنه أمر رجلا إذا أخذ مضجعه قال اللهم خلقت نفسي وأنت توفاها لك مماتها ومحياها إن أحييتها فاحفظها وإن أمتها فاغفر لها اللهم إني أسألك العافية فقال له رجل أسمعت هذا من عمر فقال من خير من عمر من رسول الله ﷺ قال ابن نافع في روايته عن عبد الله بن الحارث ولم يذكر سمعت

مسلم 6888صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Remembrance, supplication, Tawba, and seeking forgiveness
Chapter
What to say when sleeping and lying down
Numbering
Darussalam 6888
Muslim 6888