It is narrated from al-Sa'ib (may Allah have mercy on him) that he said: I was with Sayyiduna Ammar bin Yasir (may Allah be pleased with him) when a man came to him and said: "Shall I not teach you some words?" It was as if he was attributing those words to the Prophet (peace and blessings be upon him). Then he said: "When you lie down on your bed at night, say: 'Allahumma inni aslamtu nafsi ilayk, wa wajjahtu wajhi ilayk, wa fawwadtu amri ilayk, wa alja'tu zahri ilayk, amantu bi-kitabika al-munazzal, wa bi-nabiyyika al-mursal. Allahumma nafsi khalaqtaha, laka mahyaha wa laka mamatuha, in qabadtaha farhamha, wa in akhkhartaha fahfazha bi-hifz al-iman' (O Allah, I have surrendered my soul to You, turned my face towards You, entrusted my affair to You, and committed my back to Your refuge (in reliance); I believe in Your Book which was sent down and in Your Prophet who was sent. O Allah, You created my soul; its life and its death are in Your control. If You take it (during sleep), have mercy on it, and if You grant it further respite of life, protect it with faith)."
The chain of this hadith is hasan (good), and there are supporting reports (shawahid) for it in Sahih al-Bukhari and Muslim from the narration of Sayyiduna al-Bara' bin Azib (may Allah be pleased with him) and from other Companions.
Hadith Referenceالمطالب العالية بزوائد المسانيد الثمانية / كتاب الأذكار والدعوات / 3359
Hadith Gradingمحدثین:إسناده حسن صحيح
Hadith Takhrij«حکم الحدیث المطالب العالیہ محققاً تنسیق د. سعد بن ناصر بن عبد العزيز الشَّثري- مکتبہ شاملہ :قال ابن حجر: إِسْنَادُهُ حَسَنٌ ، وَلَهُ شَاهِدٌ فِي الصَّحِيحِ مِنْ حَدِيثِ الْبَرَاءِ رَضِيَ اللهُ عَنْهُ ، وَمِنْ حَدِيثِ غَيْرِهِ . » «أخرجه مصنف ابن أبي شيبة برقم: 3، وأخرجه مجمع الزوائد ومنبع الفوائد برقم: 17055، 17387، وأخرجه إتحاف الخيرة المهرة بزوائد المسانيد العشرة برقم: 6096»