Huzaifa bin Usayd reported,

Hudhayfah traced this to the Prophet ﷺ, who said, "The angel enters upon the drop of fluid after it has settled in the womb for forty or forty-five nights and asks, 'My Lord, will it be wretched or blessed?' Both are written down. Then he asks, 'My Lord, male or female?' Both are written down, along with the person's deeds, traces, lifespan, and provision. Then the pages are folded up, and nothing is added to them or taken away."

Muslim 6725

Sahih

حدثنا محمد بن عبد الله بن نمير وزهير بن حرب واللفظ لابن نمير قالا حدثنا سفيان بن عيينة عن عمرو بن دينار عن أبي الطفيل

عن حذيفة بن أسيد

يبلغ به النبي ﷺ قال يدخل الملك على النطفة بعد ما تستقر في الرحم بأربعين أو خمسة وأربعين ليلة فيقول يا رب أشقي أو سعيد فيكتبان فيقول أي رب أذكر أو أنثى فيكتبان ويكتب عمله وأثره وأجله ورزقه ثم تطوى الصحف فلا يزاد فيها ولا ينقص

مسلم 6725صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Decree
Chapter
How the human is created in his mother's womb and the recording of his provision, lifespan, deeds, misery, and happiness
Numbering
Darussalam 6725
Muslim 6725