Huzaifa bin Usayd reported,

I heard the Messenger of Allah ﷺ say, "When forty-two nights have passed over the drop of fluid, Allah sends an angel to it who shapes it and creates its hearing, sight, skin, flesh, and bones. Then the angel says, 'My Lord, is it male or female?' and your Lord decrees what He wills, and the angel writes it down. Then the angel says, 'My Lord, what is its lifespan?' and your Lord says what He wills, and the angel writes it down. Then the angel says, 'My Lord, what is its provision?' and your Lord decrees what He wills, and the angel writes it down. Then the angel goes out with the scroll in his hand, and nothing is added to what he was commanded nor anything diminished from it."In another narration, "The drop of fluid remains in the womb for forty nights, then the angel takes shape over it." Zuhayr said, "I think he said, 'the one who fashions it.'" The angel says, "My Lord, is it male or female?" and Allah makes it male or female. Then he says, "My Lord, sound or unsound?" and Allah makes it sound or unsound. Then he says, "My Lord, what is its provision, what is its lifespan, what is its nature?" Then Allah makes it wretched or happy.

Azami 541

Sahih

عن حذيفة بن أسيد الغفاري قال

سمعت رسول الله ﷺ يقول: إذا مر بالنطفة ثنتان وأربعون ليلة، بعث الله إليها ملكا فصورها، وخلق سمعها وبصرها وجلدها ولحمها وعظامها. ثم قال: يا رب أذكر أم أنثى؟ فيقضي ربك ما شاء. ويكتب الملك. ثم يقول: يا رب أجله؟ فيقول ربك ما شاء. ويكتب الملك. ثم يقول: يا رب رزقه؟ فيقضي ربك ما شاء. ويكتب الملك. ثم يخرج الملك بالصحيفة في يده فلا يزيد ما أمر ولا ينقص. وفي رواية: إن النطفة تقع في الرحم أربعين ليلة، ثم يتصور عليها الملك. قال زهير: حسبته قال: الذي يخلقها: فيقول: يا رب أذكر أو أنثى؟ فيجعله الله ذكرا أو أنثى. ثم يقول: يا رب أسوي أو غير سوي، فيجعله الله سويا أو غير سوي. ثم يقول: يا رب ما رزقه، ما أجله، ما خلقه، ثم يجعله الله شقيا أو سعيدا.

الأعظمي 541صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Belief in the angels
Section
Allah has assigned an angel to the womb who records the deeds of the human
Numbering
Jami al-Kamil 541 (2nd edition)
Azami 541