Ali said:
You people must carry out the punishment on your slaves, those of them who are married and those who are not, for a slave woman belonging to God’s Messenger committed fornication and he ordered me to beat her. But she had recently given birth to a child and I was afraid that if I beat her I might kill her, so I mentioned that to the Prophet and he said, “You have done well."
Muslim transmitted it.
In a version by Abd Dawud he said, “Leave her till her blood stops flowing and then carry out the punishment on her, and carry out* the punishment on your female slaves”.
Abu Dawud.
*Here the verb is plural.