Abdullah bin Amr reported that the Prophet ﷺ said, "When one of you marries a woman or purchases a servant, let him say, 'O Allah, I ask You for her goodness and the goodness of the nature with which You have created her, and I seek refuge in You from her evil and the evil of the nature with which You have created her.' And when one of you buys a camel, let him take hold of the top of its hump and say the same."In another wording, "When one of you acquires a wife, a servant, or a riding animal, let him take hold of its forelock and say," and he then mentioned the supplication.
عبد الله بن عمرو، عن النبي ﷺ قال: إذا تزوج أحدكم امرأة، أو اشترى خادما فليقل: اللهم إني أسألك خيرها، وخير ما جبلتها عليه، وأعوذ بك من شرها ومن شر ما جبلتها عليه، وإذا اشترى بعيرا فليأخذ بذروة سنامه وليقل مثل ذلك. وفي لفظ: إذا أفاد أحدكم امرأة، أو خادما، أو دابة، فليأخذ بناصيتها، وليقل: فذكر الحديث.
Abu Dawud (2160), Ibn Majah (1918), Ibn Sunni (100), Hakim (2/185), and Bayhaqi (7/148) all narrated it through the hadith of Muhammad bin Ajlan, from Amr bin Shuayb, who said, and then he related it. Its isnad is hasan because of Muhammad bin Ajlan and Amr bin Shuayb, for their hadiths are graded hasan. Hakim said, "Its isnad is sahih." Likewise, whoever buys a mount should say, "O Allah, I ask You for its good, and I seek refuge in You from its evil."