Anas bin Malik reported,

Allah عز وجل has assigned an angel to the womb. The angel says, "My Lord, a drop of fluid. My Lord, a clot. My Lord, a lump of flesh." When Allah wishes to decree the creation of a being, the angel asks, "My Lord, male or female? Wretched or blessed? What is his provision? What is his lifespan?" All of this is then written while he is still in his mother's womb.

Muslim 6730

Sahih

حدثني أبو كامل فضيل بن حسين الجحدري حدثنا حماد بن زيد حدثنا عبيد الله بن أبي بكر

عن أنس بن مالك ورفع الحديث أنه قال

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

مسلم 6730صحيح
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 6730
Muslim 6730