The Messenger of Allah ﷺ said, "When the drop of fluid settles in the womb for forty days or forty nights, Allah sends an angel to it. The angel asks, 'My Lord, what is its provision?' and he is told. He asks, 'My Lord, what is its lifespan?' and he is told. He asks, 'My Lord, male or female?' and he is informed. He asks, 'My Lord, wretched or blessed?' and he is informed."
حدثنا أحمد بن عبد الملك حدثنا الخطاب بن القاسم عن خصيف عن أبي الزبير
قال رسول الله ﷺ إذا استقرت النطفة في الرحم أربعين يوما أو أربعين ليلة بعث إليها ملكا فيقول يا رب ما رزقه فيقال له فيقول يا رب ما أجله فيقال له فيقول يا رب ذكر أو أنثى فيعلم فيقول يا رب شقي أو سعيد فيعلم