Abu Hurairah reported,

I heard the Messenger of Allah ﷺ say, "O Allah, Muhammad is only a human being who becomes angry as people become angry. I have made a covenant with You that You will not break with me. So whichever believer I have harmed, insulted, or lashed, make it for him an atonement and a means of nearness by which he draws closer to You on the Day of Resurrection."In another wording, "Make it for him a prayer, a purification, and a means of nearness by which he draws closer to You on the Day of Resurrection."

Azami 9641

Sahih

عن أبي هريرة قال

سمعت رسول الله ﷺ يقول: اللهم إنما محمد بشر يغضب كما يغضب البشر، وإني قد اتخذت عندك عهدا لن تخلفنيه، فأيما مؤمن آذيته، أو سببته، أو جلدته، فاجعلها له كفارة وقربة تقربه بها إليك يوم القيامة. وفي لفظ: فاجعلها له صلاة وزكاة وقربة تقربه به إليك يوم القيامة

الأعظمي 9641صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Biography of the Prophet ﷺ
Chapter
Characteristics of the Prophet ﷺ
Section
One whom the Prophet ﷺ cursed or reviled while he was not deserving of that, it would be purification, reward, and mercy for him
Numbering
Jami al-Kamil 9641 (2nd edition)
Azami 9641