Language:
كتاب الدعوات
80  
Invocations
(34)
Chapter: "If I should harm somebody, let that be a means of purification and mercy for him."
(34)
باب قَوْلِ النَّبِيِّ صلى الله عليه وسلم ‏{‏مَنْ آذَيْتُهُ فَاجْعَلْهُ لَهُ زَكَاةً وَرَحْمَةً‏}‏
Sahih al-Bukhari 6361

Narrated Abu Huraira:

that he heard the Prophet (ﷺ) saying, "O Allah! If I should ever abuse a believer, please let that be a means of bringing him near to You on the Day of Resurrection."

حَدَّثَنَا أَحْمَدُ بْنُ صَالِحٍ، حَدَّثَنَا ابْنُ وَهْبٍ، قَالَ أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، قَالَ أَخْبَرَنِي سَعِيدُ بْنُ الْمُسَيَّبِ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ أَنَّهُ سَمِعَ النَّبِيَّ صلى الله عليه وسلم يَقُولُ ‏ "‏ اللَّهُمَّ فَأَيُّمَا مُؤْمِنٍ سَبَبْتُهُ فَاجْعَلْ ذَلِكَ لَهُ قُرْبَةً إِلَيْكَ يَوْمَ الْقِيَامَةِ ‏"‏‏.‏
Reference : Sahih al-Bukhari 6361
In-book reference : Book 80, Hadith 58
USC-MSA web (English) reference : Vol. 8, Book 75, Hadith 372
  (deprecated numbering scheme)