Huzaifa bin Usayd reported,

I heard the Messenger of Allah ﷺ say, or he said, the Messenger of Allah ﷺ said, "The angel comes to the drop of fluid after it has settled in the womb for forty nights." Sufyan once said, "Or fifty and forty nights." "He says, 'My Lord, will this one be wretched or fortunate?' and Allah تبارك وتعالى decrees it, and they write it down. Then they say, 'What about the matter, male or female?' and Allah عز وجل decrees it, and they write it down. His deeds, his footsteps, his afflictions, and his provision are also written. Then the page is folded, and nothing is added to or subtracted from what it contains."

Ahmad 16142

Sahih

حدثنا سفيان عن عمرو عن أبي الطفيل

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

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

أحمد 16142صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abu Sariha Ghifari, Huzaifa bin Usayd
Numbering
Darussalam 16142
Ahmad 16142