Amir bin Wathila reported,

Abdullah bin Masud used to say, "The wretched one is he who was made wretched while still in his mother's womb, and the fortunate one is he who takes warning from the example of others."A man went to one of the companions of the Messenger of Allah ﷺ named Huzaifa bin Usayd al-Ghifari and reported to him this saying of Ibn Masud.Huzaifa asked, "How can a man be made wretched without having done any deed?"The man said to him, "Are you surprised at that?"Huzaifa replied, "Indeed, 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 forms its hearing, sight, skin, flesh, and bones. Then the angel asks, "My Lord, is it male or female?" and your Lord decrees what He wills and the angel records it. Then he asks, "My Lord, what is its lifespan?" and your Lord says what He wills and the angel records it. Then he asks, "My Lord, what is its provision?" and your Lord decrees what He wills and the angel records it. Then the angel departs with the scroll in his hand, adding nothing to what he was commanded and omitting nothing from it.'"

Azami 1001

Sahih

عن عامر بن واثلة

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

الأعظمي 1001صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Belief in the divine decree and predestination
Section
How the human is created in his mother's womb and the recording of his provision, lifespan, deeds, misery, and happiness
Numbering
Jami al-Kamil 1001 (2nd edition)
Azami 1001