BAYHAQI 15423:
from Ḥudhayfah b. Asīd Yablugh Bih —
[Machine] The Prophet ﷺ said, "The angel is entrusted with the sperm after it settles in the womb for forty days or forty-five nights. Then he asks, 'O Lord, will it be miserable or happy?' And Allah replies, 'It will be written.' Then he asks, 'O Lord, will it be a male or a female?' And Allah replies, 'It will be written.' Then its deeds, lifespan, provisions, and influence are recorded. After that, the sheets are raised and nothing is added or subtracted from it."
البيهقي ١٥٤٢٣:
عن حذيفه بن اسيد يبلغ به —
النَّبِيَّ ﷺ قَالَ يُوَكَّلُ الْمَلَكُ عَلَى النُّطْفَةِ بَعْدَ مَا تَسْتَقِرُّ فِي الرَّحِمِ أَرْبَعِينَ يَوْمًا أَوْ خَمْسًا وَأَرْبَعِينَ لَيْلَةً فَيَقُولُ أَيْ رَبِّ مَاذَا أَشَقِيٌّ أَوْ سَعِيدٌ؟ فَيَقُولُ اللهُ ﷻ فَيُكْتَبَانِ ثُمَّ يَقُولُ أَيْ رَبِّ ذَكَرٌ أَمْ أُنْثَى؟ فَيَقُولُ اللهُ ﷻ فَيُكْتَبَانِ فَيُكْتَبُ عَمَلُهُ وَأَجَلُهُ وَرِزْقُهُ وَأَثَرُهُ ثُمَّ تُرْفَعُ الصُّحُفُ فَلَا يُزَادُ فِيهَا وَلَا يُنْقَصُ
hadithunlocked.com