It is narrated from Sayyiduna Ibn Umar (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "When Allah Almighty intends to create a soul, the angel appointed over the wombs, presenting (the matter before the Divine Court), says: 'O my Lord! Will (it) be a male or a female?' So Allah Almighty gives His decision. Then that angel says: 'O my Lord! Will (it) be wretched or fortunate?' So Allah Almighty issues His decision. Then between its two eyes is written everything it is going to meet, even the slight misfortune that will befall it."
I (al-Busiri) say: Imam al-Bazzar recorded it in his Musnad: Salim (may Allah have mercy on him) narrates from his father (Sayyiduna Abdullah bin Umar, may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "When the sperm-drop is created in the womb, the angel of the wombs says: 'O my Lord! What shall I write?' So Allah Almighty issues His decision to him. Then he says: '(Is it) a male or a female?' So Allah Almighty gives His command to him" (then the narrator mentioned the whole hadith).
Imam al-Bazzar said that Salih (may Allah have mercy on him) is alone in narrating this hadith from (Imam) al-Zuhri (may Allah have mercy on him); that is what he said.