The Messenger of Allah ﷺ said, "If the slave-girl of one of you commits fornication, let him flog her and not rebuke her. If she does it again, let him flog her and not rebuke her. If she does it again, let him flog her and not rebuke her. If she does it a fourth time, let him sell her, even for a rope of hair or a braid of hair."
حدثنا محمد بن عبيد حدثنا عبيد الله عن سعيد بن أبي سعيد
أن رسول الله ﷺ قال إذا زنت أمة أحدكم فليجلدها ولا يعيرها فإن عادت فليجلدها ولا يعيرها فإن عادت فليجلدها ولا يعيرها فإن عادت في الرابعة فليبعها ولو بحبل من شعر أو ضفير من شعر
Its isnad is sahih. The imams narrated it with similar wording, Bukhari 3/193 in the chapter on manumission, on the dislike of harshness toward slaves, Muslim 3/1328 no. 1703 in the chapter on legal punishments, on stoning Jews and protected non-Muslims for fornication, and Tirmidhi 4/46 no. 1440 in the chapter on legal punishments, on applying the punishment to female slaves, where he said, hasan sahih. And Tayalisi 1/300 no. 1527, from Abu Hurairah and from Zayd bin Khalid, and Ibn Abu Shayba 14/159, and Abdul-Razzaq 7/393 no. 13599.